196 references to FileUtilities
Microsoft.Build.Utilities.Core (106)
BuildEnvironmentHelper.cs (9)
150var vsRoot = FileUtilities.GetFolderAbove(vsProcess, 3); 202var msBuildExe = Path.Combine(FileUtilities.GetFolderAbove(buildAssembly), "MSBuild.exe"); 203var msBuildDll = Path.Combine(FileUtilities.GetFolderAbove(buildAssembly), "MSBuild.dll"); 360return FileUtilities.GetFolderAbove(msBuildAssembly, 369return FileUtilities.CombinePaths( 445return FileUtilities.ExecutingAssemblyPath; 604var potentialAmd64FromX86 = FileUtilities.CombinePaths(MSBuildToolsDirectoryRoot, "amd64", msBuildExeName); 605var potentialARM64FromX86 = FileUtilities.CombinePaths(MSBuildToolsDirectoryRoot, "arm64", msBuildExeName); 677defaultSdkPath = FileUtilities.CombinePaths(VisualStudioInstallRootDirectory, "MSBuild", "Sdks");
CommandLineBuilder.cs (1)
334fileName = FileUtilities.FixFilePath(fileName);
DebugUtils.cs (5)
32string environmentDebugPath = FileUtilities.TrimAndStripAnyQuotes(Environment.GetEnvironmentVariable("MSBUILDDEBUGPATH")); 37if (!string.IsNullOrWhiteSpace(debugDirectory) && FileUtilities.CanWriteToDirectory(debugDirectory)) 41else if (FileUtilities.CanWriteToDirectory(Directory.GetCurrentDirectory())) 47debugDirectory = Path.Combine(FileUtilities.TempFileDirectory, "MSBuild_Logs"); 59FileUtilities.EnsureDirectoryExists(debugDirectory);
ErrorUtilities.cs (1)
543if (FileUtilities.PathIsInvalid(parameter))
ExceptionHandling.cs (3)
74: FileUtilities.TempFileDirectory; 359using (StreamWriter writer = FileUtilities.OpenWrite(s_dumpFileName, append: true)) 366using (StreamWriter writer = FileUtilities.OpenWrite(s_dumpFileName, append: true))
FileMatcher.cs (17)
39internal static readonly char[] directorySeparatorCharacters = FileUtilities.Slashes; 224path = FileUtilities.FixFilePath(path); 588filespec = FileUtilities.FixFilePath(filespec); 862Debug.Assert(FileUtilities.PathsEqual(searchToExclude.BaseDirectory, recursionState.BaseDirectory), "Expected exclude search base directory to match include search base directory"); 1237bool isSurroundedBySlashes = (i == 0 || FileUtilities.IsAnySlash(str[i - 1])) 1238&& i < str.Length - 2 && FileUtilities.IsAnySlash(str[i + 2]); 1374else if (FileUtilities.IsAnySlash(ch)) 1419if (startIndex >= str.Length || !FileUtilities.IsAnySlash(str[startIndex])) 1428bool isSeparator = i < str.Length - 1 && FileUtilities.IsAnySlash(str[i + 1]); 1429bool isRelativeSeparator = i < str.Length - 2 && str[i + 1] == '.' && FileUtilities.IsAnySlash(str[i + 2]); 2127FileUtilities.IsAnySlash(wildcard[2]) && 2128FileUtilities.IsAnySlash(wildcard[wildcardLength - 3]) && 2133if (wildcard.IndexOfAny(FileUtilities.Slashes, 3, wildcardLength - 6) == -1) 2294if (!FileUtilities.IsAnySlash(directoryPart[i])) 2324while (index < aString.Length && FileUtilities.IsAnySlash(aString[index])) 2341if (FileUtilities.PathsEqual(filespecUnescaped, excludeSpec)) 2657int index = directoryPath.LastIndexOfAny(FileUtilities.Slashes);
FileUtilities.cs (1)
747internal static string ExecutingAssemblyPath => Path.GetFullPath(AssemblyUtilities.GetAssemblyLocation(typeof(FileUtilities).GetTypeInfo().Assembly));
FrameworkLocationHelper.cs (1)
1535this._pathToDotNetFrameworkReferenceAssemblies = FileUtilities.EnsureTrailingSlash(referencePath);
Modifiers.cs (31)
110if (name == FileUtilities.ItemSpecModifiers.RootDir) 126if (name == FileUtilities.ItemSpecModifiers.FullPath) 130if (name == FileUtilities.ItemSpecModifiers.Filename) 138if (name == FileUtilities.ItemSpecModifiers.Identity) 153if (name == FileUtilities.ItemSpecModifiers.Directory) 161if (name == FileUtilities.ItemSpecModifiers.Extension) 176if (name == FileUtilities.ItemSpecModifiers.CreatedTime) 184if (name == FileUtilities.ItemSpecModifiers.RelativeDir) 200if (name == FileUtilities.ItemSpecModifiers.AccessedTime) 208if (name == FileUtilities.ItemSpecModifiers.ModifiedTime) 216if (name == FileUtilities.ItemSpecModifiers.RecursiveDir) 256if (name == FileUtilities.ItemSpecModifiers.DefiningProjectName) 262if (name == FileUtilities.ItemSpecModifiers.DefiningProjectFullPath) 274if (name == FileUtilities.ItemSpecModifiers.DefiningProjectDirectory) 282if (name == FileUtilities.ItemSpecModifiers.DefiningProjectExtension) 392if (string.Equals(modifier, FileUtilities.ItemSpecModifiers.FullPath, StringComparison.OrdinalIgnoreCase)) 409else if (string.Equals(modifier, FileUtilities.ItemSpecModifiers.RootDir, StringComparison.OrdinalIgnoreCase)) 425else if (string.Equals(modifier, FileUtilities.ItemSpecModifiers.Filename, StringComparison.OrdinalIgnoreCase)) 440else if (string.Equals(modifier, FileUtilities.ItemSpecModifiers.Extension, StringComparison.OrdinalIgnoreCase)) 454else if (string.Equals(modifier, FileUtilities.ItemSpecModifiers.RelativeDir, StringComparison.OrdinalIgnoreCase)) 458else if (string.Equals(modifier, FileUtilities.ItemSpecModifiers.Directory, StringComparison.OrdinalIgnoreCase)) 495else if (string.Equals(modifier, FileUtilities.ItemSpecModifiers.RecursiveDir, StringComparison.OrdinalIgnoreCase)) 500else if (string.Equals(modifier, FileUtilities.ItemSpecModifiers.Identity, StringComparison.OrdinalIgnoreCase)) 504else if (string.Equals(modifier, FileUtilities.ItemSpecModifiers.ModifiedTime, StringComparison.OrdinalIgnoreCase)) 510FileInfo info = FileUtilities.GetFileInfoNoThrow(unescapedItemSpec); 522else if (string.Equals(modifier, FileUtilities.ItemSpecModifiers.CreatedTime, StringComparison.OrdinalIgnoreCase)) 538else if (string.Equals(modifier, FileUtilities.ItemSpecModifiers.AccessedTime, StringComparison.OrdinalIgnoreCase)) 563if (string.Equals(modifier, FileUtilities.ItemSpecModifiers.DefiningProjectDirectory, StringComparison.OrdinalIgnoreCase)) 574if (string.Equals(modifier, FileUtilities.ItemSpecModifiers.DefiningProjectFullPath, StringComparison.OrdinalIgnoreCase)) 578else if (string.Equals(modifier, FileUtilities.ItemSpecModifiers.DefiningProjectName, StringComparison.OrdinalIgnoreCase)) 582else if (string.Equals(modifier, FileUtilities.ItemSpecModifiers.DefiningProjectExtension, StringComparison.OrdinalIgnoreCase))
PrintLineDebuggerWriters.cs (1)
74var executingAssembly = FileUtilities.ExecutingAssemblyPath;
TargetPlatformSDK.cs (1)
108set => _path = value != null ? FileUtilities.EnsureTrailingSlash(value) : null;
TaskItem.cs (13)
102_itemSpec = treatAsFilePath ? FileUtilities.FixFilePath(itemSpec) : itemSpec; 129if (!FileUtilities.ItemSpecModifiers.IsDerivableItemSpecModifier(key)) 150_definingProject = EscapingUtilities.EscapeWithCaching(sourceItem.GetMetadata(FileUtilities.ItemSpecModifiers.DefiningProjectFullPath)); 155_definingProject = sourceItemAsITaskItem2.GetMetadataValueEscaped(FileUtilities.ItemSpecModifiers.DefiningProjectFullPath); 182_itemSpec = FileUtilities.FixFilePath(value); 201_itemSpec = FileUtilities.FixFilePath(value); 214int count = (_metadata?.Count ?? 0) + FileUtilities.ItemSpecModifiers.All.Length; 223metadataNames.AddRange(FileUtilities.ItemSpecModifiers.All); 233public int MetadataCount => (_metadata?.Count ?? 0) + FileUtilities.ItemSpecModifiers.All.Length; 264ErrorUtilities.VerifyThrowArgument(!FileUtilities.ItemSpecModifiers.IsItemSpecModifier(metadataName), 286ErrorUtilities.VerifyThrowArgument(!FileUtilities.ItemSpecModifiers.IsDerivableItemSpecModifier(metadataName), 456if (FileUtilities.ItemSpecModifiers.IsDerivableItemSpecModifier(metadataName)) 460metadataValue = FileUtilities.ItemSpecModifiers.GetItemSpecModifier(null, _itemSpec, _definingProject, metadataName, ref _fullPath);
TaskLoggingHelper.cs (1)
1329using (StreamReader fileStream = FileUtilities.OpenRead(fileName, Encoding.GetEncoding(0))) // HIGHCHAR: Use ANSI for logging messages.
TempFileUtilities.cs (1)
74return FileUtilities.EnsureTrailingSlash(basePath);
ToolLocationHelper.cs (14)
660if (FileUtilities.DirectoryExistsNoThrow(legacyWindowsMetadataLocation)) 662legacyWindowsMetadataLocation = FileUtilities.EnsureTrailingSlash(legacyWindowsMetadataLocation); 1765return FileUtilities.EnsureNoTrailingSlash(referenceAssemblyDirectory); 1839return FileUtilities.EnsureNoTrailingSlash(legacyMsCorlib20Path); 1856return FileUtilities.EnsureNoTrailingSlash(referenceAssemblyDirectory); 2422if (FileUtilities.DirectoryExistsNoThrow(referenceAssemblyPath)) 2424referenceAssemblyPath = FileUtilities.EnsureTrailingSlash(referenceAssemblyPath); 2548if (FileUtilities.FileExistsNoThrow(pathToSDKManifest)) 2550targetPlatformSDK.ExtensionSDKs.Add(SDKKey, FileUtilities.EnsureTrailingSlash(sdkVersionDirectory.FullName)); 2817if (FileUtilities.DirectoryExistsNoThrow(directoryName)) 2823targetPlatformSDK.ExtensionSDKs.Add(sdkKey, FileUtilities.EnsureTrailingSlash(directoryName)); 2930diskRoots.RemoveAll(x => !FileUtilities.DirectoryExistsNoThrow(x)); 3051if (FileUtilities.FileExistsNoThrow(pathToPlatformManifest)) 3053sdk.Platforms.Add(sdkKey, FileUtilities.EnsureTrailingSlash(platformVersion.FullName));
ToolsetElement.cs (1)
85string tempFileName = FileUtilities.GetTemporaryFile();
ToolTask.cs (4)
597responseFile = FileUtilities.GetTemporaryFileName(".rsp"); 600using (StreamWriter responseFileStream = FileUtilities.OpenWrite(responseFile, false, ResponseFileEncoding)) 1409_temporaryBatchFile = FileUtilities.GetTemporaryFile(".cmd"); 1416_temporaryBatchFile = FileUtilities.GetTemporaryFile(".sh");
TrackedDependencies\TrackedDependencies.cs (1)
81if (!FileUtilities.FileExistsNoThrow(item.ItemSpec))
Microsoft.Build.Utilities.UnitTests (90)
CommandLineBuilder_Tests.cs (2)
110c.AppendFileNamesIfNotNull(new[] { "Form1.resx", FileUtilities.FixFilePath("built\\Form1.resources") }, ","); 114c.ShouldBe(FileUtilities.FixFilePath(@"Form1.resx,built\Form1.resources"));
NativeMethodsShared_Tests.cs (3)
77string nonexistentFile = FileUtilities.GetTemporaryFileName(); 90string directory = FileUtilities.GetTemporaryDirectory(createDirectory: true); 103string file = FileUtilities.GetTemporaryFile();
PlatformManifest_Tests.cs (7)
43manifestDirectory = FileUtilities.GetTemporaryDirectory(); 52FileUtilities.DeleteDirectoryNoThrow(manifestDirectory, recursive: true); 68manifestDirectory = FileUtilities.GetTemporaryDirectory(); 78FileUtilities.DeleteDirectoryNoThrow(manifestDirectory, recursive: true); 325_manifestDirectory = FileUtilities.GetTemporaryDirectory(); 333if (FileUtilities.DirectoryExistsNoThrow(_manifestDirectory)) 335FileUtilities.DeleteDirectoryNoThrow(_manifestDirectory, recursive: true);
TaskItem_Tests.cs (32)
45to.GetMetadata(FileUtilities.ItemSpecModifiers.Filename).ShouldBe("Monkey"); 46to.GetMetadata(FileUtilities.ItemSpecModifiers.Extension).ShouldBe(".txt"); 47to.GetMetadata(FileUtilities.ItemSpecModifiers.RelativeDir).ShouldBe(string.Empty); 92taskItem.MetadataNames.Cast<string>().ShouldBeSetEquivalentTo(FileUtilities.ItemSpecModifiers.All); 93taskItem.MetadataCount.ShouldBe(FileUtilities.ItemSpecModifiers.All.Length); 98taskItem.MetadataNames.Cast<string>().ShouldBeSetEquivalentTo(FileUtilities.ItemSpecModifiers.All.Concat(new[] { "m" })); 99taskItem.MetadataCount.ShouldBe(FileUtilities.ItemSpecModifiers.All.Length + 1); 117h[FileUtilities.ItemSpecModifiers.Filename] = "foo"; 118h[FileUtilities.ItemSpecModifiers.Extension] = "bar"; 124t.GetMetadata(FileUtilities.ItemSpecModifiers.Filename).ShouldBe("bamboo"); 125t.GetMetadata(FileUtilities.ItemSpecModifiers.Extension).ShouldBe(".baz"); 138t.SetMetadata(FileUtilities.ItemSpecModifiers.FullPath, "bazbaz"); 158t.RemoveMetadata(FileUtilities.ItemSpecModifiers.RootDir); 173t.MetadataCount.ShouldBe(FileUtilities.ItemSpecModifiers.All.Length); 177t.MetadataCount.ShouldBe(FileUtilities.ItemSpecModifiers.All.Length + 1); 185from.GetMetadata(FileUtilities.ItemSpecModifiers.FullPath).ShouldBe( 196from.GetMetadata(FileUtilities.ItemSpecModifiers.RootDir).ShouldBe(Path.GetPathRoot(from.GetMetadata(FileUtilities.ItemSpecModifiers.FullPath))); 204from.GetMetadata(FileUtilities.ItemSpecModifiers.Filename).ShouldBe("Monkey"); 212from.GetMetadata(FileUtilities.ItemSpecModifiers.Extension).ShouldBe(".txt"); 220from.GetMetadata(FileUtilities.ItemSpecModifiers.RelativeDir).Length.ShouldBe(0); 228from.GetMetadata(FileUtilities.ItemSpecModifiers.Directory).ShouldBe(NativeMethodsShared.IsWindows ? @"subdir\" : "subdir/"); 236from.GetMetadata(FileUtilities.ItemSpecModifiers.Directory).ShouldBe(@"subdir\"); 245from.GetMetadata(FileUtilities.ItemSpecModifiers.RecursiveDir).Length.ShouldBe(0); 253from.GetMetadata(FileUtilities.ItemSpecModifiers.Identity).ShouldBe("Monkey.txt"); 260from.ItemSpec = FileUtilities.GetTemporaryFile(); 262from.GetMetadata(FileUtilities.ItemSpecModifiers.ModifiedTime).Length.ShouldBeGreaterThan(0); 264from.GetMetadata(FileUtilities.ItemSpecModifiers.CreatedTime).Length.ShouldBeGreaterThan(0); 266from.GetMetadata(FileUtilities.ItemSpecModifiers.AccessedTime).Length.ShouldBeGreaterThan(0); 270from.GetMetadata(FileUtilities.ItemSpecModifiers.ModifiedTime).Length.ShouldBe(0); 272from.GetMetadata(FileUtilities.ItemSpecModifiers.CreatedTime).Length.ShouldBe(0); 274from.GetMetadata(FileUtilities.ItemSpecModifiers.AccessedTime).Length.ShouldBe(0);
TaskLoggingHelper_Tests.cs (1)
176file = FileUtilities.GetTemporaryFileName();
TestAssemblyInfo.cs (1)
76FileUtilities.ClearTempFileDirectory();
ToolLocationHelper_Tests.cs (41)
91FileUtilities.DeleteWithoutTrailingBackslash(tempDirectory, true); 218FileUtilities.DeleteDirectoryNoThrow(platformRootFolder, true); 243FileUtilities.DeleteWithoutTrailingBackslash(tempDirectory, true); 268FileUtilities.DeleteWithoutTrailingBackslash(tempDirectory, true); 294FileUtilities.DeleteWithoutTrailingBackslash(tempDirectory, true); 320FileUtilities.DeleteWithoutTrailingBackslash(tempDirectory, true); 363FileUtilities.DeleteWithoutTrailingBackslash(tempDirectory, true); 482FileUtilities.DeleteWithoutTrailingBackslash(tempDirectory, true); 615FileUtilities.DeleteWithoutTrailingBackslash(fakeEverettPath); 1415FileUtilities.DeleteWithoutTrailingBackslash(redist40Directory, true); 1420FileUtilities.DeleteWithoutTrailingBackslash(redist41Directory, true); 1450FileUtilities.DeleteWithoutTrailingBackslash(redist41Directory, true); 1480FileUtilities.DeleteWithoutTrailingBackslash(redist41Directory, true); 1510FileUtilities.DeleteWithoutTrailingBackslash(redist41Directory, true); 1540FileUtilities.DeleteWithoutTrailingBackslash(redist40Directory, true); 1572FileUtilities.DeleteWithoutTrailingBackslash(redist41Directory, true); 1607FileUtilities.DeleteWithoutTrailingBackslash(redist41Directory, true); 1641FileUtilities.DeleteWithoutTrailingBackslash(redist41Directory, true); 1704FileUtilities.DeleteWithoutTrailingBackslash(framework41Directory, true); 1709FileUtilities.DeleteWithoutTrailingBackslash(framework40Directory, true); 1714FileUtilities.DeleteWithoutTrailingBackslash(framework39Directory, true); 1765FileUtilities.DeleteWithoutTrailingBackslash(framework40Directory, true); 1770FileUtilities.DeleteWithoutTrailingBackslash(framework39Directory, true); 1821FileUtilities.DeleteWithoutTrailingBackslash(framework41Directory, true); 1826FileUtilities.DeleteWithoutTrailingBackslash(framework40Directory, true); 2204string dotNet40Path = FileUtilities.EnsureNoTrailingSlash(referencePaths[0]); 2287string dotNet40Path = FileUtilities.EnsureNoTrailingSlash(referencePaths[0]); 2946if (FileUtilities.DirectoryExistsNoThrow(_fakeStructureRoot)) 2948FileUtilities.DeleteDirectoryNoThrow(_fakeStructureRoot, true); 2954if (FileUtilities.DirectoryExistsNoThrow(_fakeStructureRoot2)) 2956FileUtilities.DeleteDirectoryNoThrow(_fakeStructureRoot2, true); 3271FileUtilities.DeleteWithoutTrailingBackslash(frameworkPath, true /* for recursive deletion */); 3272FileUtilities.DeleteWithoutTrailingBackslash(frameworkPath2, true /* for recursive deletion */); 3406FileUtilities.DeleteWithoutTrailingBackslash(manifestPath, true /* for recursive deletion */); 3467FileUtilities.DeleteWithoutTrailingBackslash(manifestPath, true /* for recursive deletion */); 3573FileUtilities.DeleteDirectoryNoThrow(testDirectoryRoot, true); 3604FileUtilities.DeleteDirectoryNoThrow(testDirectoryRoot, true); 3645FileUtilities.DeleteDirectoryNoThrow(testDirectoryRoot, true); 3673FileUtilities.DeleteDirectoryNoThrow(testDirectoryRoot, true); 4533FileUtilities.DeleteDirectoryNoThrow(tempPath, true); 4568FileUtilities.DeleteDirectoryNoThrow(tempPath, true);
ToolTask_Tests.cs (3)
448string tempFile = FileUtilities.GetTemporaryFileName(); 476string tempFile = FileUtilities.GetTemporaryFileName(); 507string tempFile = FileUtilities.GetTemporaryFileName();