897 references to NativeMethods
Microsoft.Build (161)
AssemblyInfo.cs (1)
4global using NativeMethodsShared = Microsoft.Build.Framework.NativeMethods;
BackEnd\BuildManager\BuildManager.cs (2)
471if (NativeMethodsShared.IsWindows || parameters.LowPriority) 1078_buildTelemetry.FrameworkName = NativeMethodsShared.FrameworkName;
BackEnd\BuildManager\BuildParameters.cs (1)
67private static string s_startupDirectory = NativeMethodsShared.GetCurrentDirectory();
BackEnd\Client\MSBuildClient.cs (2)
232NativeMethodsShared.RestoreConsoleMode(_originalConsoleMode); 376(var acceptAnsiColorCodes, var outputIsScreen, _originalConsoleMode) = NativeMethodsShared.QueryIsScreenAndTryEnableAnsiColorCodes();
BackEnd\Components\BuildRequestEngine\BuildRequestEngine.cs (4)
840if (!NativeMethodsShared.IsWindows || BuildEnvironmentHelper.Instance.RunningInVisualStudio) 856NativeMethodsShared.MemoryStatus memoryStatus = NativeMethodsShared.GetMemoryStatus(); 891memoryStatus = NativeMethodsShared.GetMemoryStatus();
BackEnd\Components\Caching\ResultsCache.cs (1)
252capacity => new ConcurrentDictionary<int, BuildResult>(NativeMethodsShared.GetLogicalCoreCount(), capacity));
BackEnd\Components\Communications\CurrentHost.cs (1)
31NativeMethodsShared.IsWindows ? "dotnet.exe" : "dotnet");
BackEnd\Components\Communications\NodeLauncher.cs (3)
101if (!NativeMethodsShared.IsWindows) 181NativeMethodsShared.CloseHandle(processInfo.hProcess); 186NativeMethodsShared.CloseHandle(processInfo.hThread);
BackEnd\Components\RequestBuilder\RequestBuilder.cs (4)
904entryToComplete.RequestConfiguration.SavedCurrentDirectory = NativeMethodsShared.GetCurrentDirectory(); 1096NativeMethodsShared.SetCurrentDirectory(_requestEntry.ProjectRootDirectory); 1268_requestEntry.RequestConfiguration.SavedCurrentDirectory = NativeMethodsShared.GetCurrentDirectory(); 1302NativeMethodsShared.SetCurrentDirectory(_requestEntry.RequestConfiguration.SavedCurrentDirectory);
BackEnd\Components\RequestBuilder\TargetUpToDateChecker.cs (5)
984oldestOutputFileTime = NativeMethodsShared.GetLastWriteFileUtcTime(oldestOutputFullPath); 1009candidateOutputFileTime = NativeMethodsShared.GetLastWriteFileUtcTime(candidateOutputFullPath); 1044inputFileTime = NativeMethodsShared.GetLastWriteFileUtcTime(unescapedInputFullPath); 1197var path1WriteTime = NativeMethodsShared.GetLastWriteFileUtcTime(path1); 1200var path2WriteTime = NativeMethodsShared.GetLastWriteFileUtcTime(path2);
BackEnd\Components\RequestBuilder\TaskBuilder.cs (1)
419NativeMethodsShared.SetCurrentDirectory(_buildRequestEntry.ProjectRootDirectory);
BackEnd\Components\Scheduler\Scheduler.cs (1)
213_coreLimit = NativeMethodsShared.GetLogicalCoreCount();
BackEnd\Components\SdkResolution\SdkResolverService.cs (1)
578NativeMethodsShared.GetLogicalCoreCount(),
BackEnd\Node\InProcNode.cs (3)
143_savedCurrentDirectory = NativeMethodsShared.GetCurrentDirectory(); 336NativeMethodsShared.SetCurrentDirectory(_savedCurrentDirectory); 468_savedCurrentDirectory = NativeMethodsShared.GetCurrentDirectory();
BackEnd\Node\OutOfProcNode.cs (4)
473NativeMethodsShared.SetCurrentDirectory(BuildEnvironmentHelper.Instance.CurrentMSBuildToolsDirectory); 704NativeMethodsShared.SetCurrentDirectory(BuildParameters.StartupDirectory); 709NativeMethodsShared.SetCurrentDirectory(BuildEnvironmentHelper.Instance.CurrentMSBuildToolsDirectory); 857if (!lowPriority || NativeMethodsShared.IsWindows)
BackEnd\Node\OutOfProcServerNode.cs (3)
252NativeMethodsShared.SetCurrentDirectory(BuildEnvironmentHelper.Instance.CurrentMSBuildToolsDirectory); 391if (NativeMethodsShared.IsWindows && command.ConsoleConfiguration.BufferWidth > 0) 426NativeMethodsShared.SetCurrentDirectory(BuildEnvironmentHelper.Instance.CurrentMSBuildToolsDirectory);
BackEnd\Shared\BuildRequestConfiguration.cs (2)
444NativeMethodsShared.SetCurrentDirectory(BuildParameters.StartupDirectory); 449NativeMethodsShared.SetCurrentDirectory(
BuildEnvironmentHelper.cs (12)
139if (!NativeMethodsShared.IsWindows) 171if (NativeMethodsShared.IsWindows && 244if (NativeMethodsShared.IsWindows && 374NativeMethodsShared.ProcessorArchitecture == Framework.NativeMethods.ProcessorArchitectures.X64 ? "amd64" : 375NativeMethodsShared.ProcessorArchitecture == Framework.NativeMethods.ProcessorArchitectures.ARM64 ? "arm64" : string.Empty, 580MSBuildToolsDirectoryRoot = NativeMethodsShared.ProcessorArchitecture switch 582NativeMethodsShared.ProcessorArchitectures.X86 => CurrentMSBuildToolsDirectory, 583NativeMethodsShared.ProcessorArchitectures.X64 or NativeMethodsShared.ProcessorArchitectures.ARM64 585_ => throw new InternalErrorException("Unknown processor architecture " + NativeMethodsShared.ProcessorArchitecture),
CommunicationsUtilities.cs (1)
517if (!NativeMethodsShared.IsWindows)
Construction\ProjectRootElement.cs (3)
171_directory = NativeMethodsShared.GetCurrentDirectory(); 188_directory = NativeMethodsShared.GetCurrentDirectory(); 245_directory = NativeMethodsShared.GetCurrentDirectory();
Definition\ToolsetReader.cs (2)
173var libraryPath = NativeMethodsShared.FrameworkBasePath; 529var importSearchPathsTable = GetProjectImportSearchPathsTable(toolsVersion.Name, NativeMethodsShared.GetOSNameForExtensionsPath());
Evaluation\Evaluator.cs (3)
1144if (!NativeMethodsShared.IsWindows) 1146SetBuiltInProperty(ReservedPropertyNames.osName, NativeMethodsShared.OSName); 1147SetBuiltInProperty(ReservedPropertyNames.frameworkToolsRoot, NativeMethodsShared.FrameworkBasePath);
Evaluation\Expander.cs (3)
1649if (!NativeMethodsShared.IsWindows || !ChangeWaves.AreFeaturesEnabled(ChangeWaves.Wave17_4)) 1689if (!NativeMethodsShared.IsWindows && !registryKeyName.StartsWith("HKEY_CURRENT_USER", StringComparison.OrdinalIgnoreCase)) 1699return NativeMethodsShared.FrameworkBasePath + Path.DirectorySeparatorChar;
Evaluation\IntrinsicFunctions.cs (8)
196if (!NativeMethodsShared.IsWindows || !ChangeWaves.AreFeaturesEnabled(ChangeWaves.Wave17_4)) 213if (!NativeMethodsShared.IsWindows || !ChangeWaves.AreFeaturesEnabled(ChangeWaves.Wave17_4)) 227if (!NativeMethodsShared.IsWindows || !ChangeWaves.AreFeaturesEnabled(ChangeWaves.Wave17_4)) 250if (!NativeMethodsShared.IsWindows || !ChangeWaves.AreFeaturesEnabled(ChangeWaves.Wave17_4)) 281if (!NativeMethodsShared.IsWindows && !keyName.StartsWith("HKEY_CURRENT_USER", StringComparison.OrdinalIgnoreCase)) 290return Path.Combine(NativeMethodsShared.FrameworkBasePath, m.Groups[0].Value) + Path.DirectorySeparatorChar; 555return NativeMethodsShared.IsUnixLike; 564return NativeMethodsShared.IsBSD;
FileMatcher.cs (5)
1053if (NativeMethodsShared.IsLinux && recursionState.SearchData.DirectoryPattern != null) 1194using (var matchFileExpression = new ReuseableStringBuilder(FileSpecRegexMinLength + NativeMethodsShared.MAX_PATH)) 1259bool isUncPath = NativeMethodsShared.IsWindows && fixedDir.Length > 1 2255if (NativeMethodsShared.IsWindows && 2576var maxTasks = Math.Max(1, NativeMethodsShared.GetLogicalCoreCount() / 2);
FileSystems.cs (1)
20if (NativeMethodsShared.IsWindows)
FileUtilities.cs (9)
160if (NativeMethodsShared.GetLastWriteDirectoryUtcTime(directoryPath, out lastModifiedTime)) 564if (NativeMethodsShared.IsWindows || string.IsNullOrEmpty(value) 585if (NativeMethodsShared.IsWindows || value.IsEmpty) 670if (NativeMethodsShared.IsWindows) 764if (NativeMethodsShared.IsWindows && !EndsWithSlash(fullPath)) 1205return path.Length >= NativeMethodsShared.MaxPath; 1210bool hasMaxPath = NativeMethodsShared.HasMaxPath; 1211int maxPath = NativeMethodsShared.MaxPath; 1213return hasMaxPath && !IsRootedNoThrow(path) && NativeMethodsShared.GetCurrentDirectory().Length + path.Length + 1 /* slash */ >= maxPath;
FrameworkLocationHelper.cs (35)
90internal static string dotNetFrameworkVersionFolderPrefixV11 = NativeMethodsShared.IsWindows ? "v1.1" : "1.1"; // v1.1 is for Everett. 95internal static string dotNetFrameworkVersionFolderPrefixV20 = NativeMethodsShared.IsWindows ? "v2.0" : "2.0"; // v2.0 is for Whidbey. 99internal static string dotNetFrameworkVersionFolderPrefixV30 = NativeMethodsShared.IsWindows ? "v3.0" : "3.0"; // v3.0 is for WinFx. 113internal static string dotNetFrameworkVersionFolderPrefixV35 = NativeMethodsShared.IsWindows ? "v3.5" : "3.5"; // v3.5 is for Orcas. 119internal static string dotNetFrameworkVersionFolderPrefixV40 = NativeMethodsShared.IsWindows ? "v4.0" : "4.0"; 120internal static string dotNetFrameworkVersionFolderPrefixV45 = NativeMethodsShared.IsWindows ? "v4.5" : "4.5"; 409return NativeMethodsShared.IsUnixLike 410? Path.Combine(NativeMethodsShared.FrameworkBasePath, dotNetFrameworkVersionFolderPrefixV11) 419return NativeMethodsShared.IsUnixLike 420? Path.Combine(NativeMethodsShared.FrameworkBasePath, dotNetFrameworkVersionFolderPrefixV20) 429return NativeMethodsShared.IsUnixLike 430? Path.Combine(NativeMethodsShared.FrameworkBasePath, dotNetFrameworkVersionFolderPrefixV30) 439return NativeMethodsShared.IsUnixLike 440? Path.Combine(NativeMethodsShared.FrameworkBasePath, dotNetFrameworkVersionFolderPrefixV35) 449return NativeMethodsShared.IsUnixLike 450? Path.Combine(NativeMethodsShared.FrameworkBasePath, dotNetFrameworkVersionFolderPrefixV40) 459return NativeMethodsShared.IsUnixLike 460? Path.Combine(NativeMethodsShared.FrameworkBasePath, dotNetFrameworkVersionFolderPrefixV45) 469return NativeMethodsShared.IsUnixLike 470? Path.Combine(NativeMethodsShared.FrameworkBasePath, dotNetFrameworkVersionFolderPrefixV11) 479return NativeMethodsShared.IsUnixLike 480? Path.Combine(NativeMethodsShared.FrameworkBasePath, dotNetFrameworkVersionFolderPrefixV20) 503if (!NativeMethodsShared.IsWindows) 505s_fallbackDotNetFrameworkSdkInstallPath = NativeMethodsShared.FrameworkCurrentPath; 553if (NativeMethodsShared.IsWindows) 600if (NativeMethodsShared.IsWindows) 774if (!NativeMethodsShared.IsWindows) 782var frameworkPath = Path.Combine(NativeMethodsShared.FrameworkBasePath, prefix ?? string.Empty); 928combinedPath = NativeMethodsShared.IsWindows 930: Path.Combine(NativeMethodsShared.FrameworkBasePath, "xbuild-frameworks"); 1142dotNetFrameworkVersionFolderPrefix: NativeMethodsShared.IsWindows ? "v4.0" : "v4.5", 1395(!FileSystems.Default.FileExists(Path.Combine(generatedPathToDotNetFramework, NativeMethodsShared.IsWindows ? "MSBuild.exe" : "mcs.exe")) && 1423if (NativeMethodsShared.IsUnixLike) 1425string frameworkPath = NativeMethodsShared.FrameworkBasePath; 1514if (NativeMethodsShared.IsWindows)
Graph\ProjectGraph.cs (2)
341NativeMethodsShared.GetLogicalCoreCount(), 382NativeMethodsShared.GetLogicalCoreCount(),
Instance\HostServices.cs (1)
90if (NativeMethodsShared.IsWindows)
Instance\RunningObjectTable.cs (1)
26if (!NativeMethodsShared.IsWindows)
Instance\TaskFactories\TaskHostTask.cs (1)
268NativeMethodsShared.GetCurrentDirectory(),
Logging\BaseConsoleLogger.cs (1)
265runningWithCharacterFileType = NativeMethodsShared.IsWindows && ConsoleConfiguration.OutputIsScreen;
Logging\InProcessConsoleConfiguration.cs (10)
27if (NativeMethodsShared.IsWindows && !Console.IsOutputRedirected) 31IntPtr stdOut = NativeMethodsShared.GetStdHandle(NativeMethodsShared.STD_OUTPUT_HANDLE); 32if (NativeMethodsShared.GetConsoleMode(stdOut, out uint consoleMode)) 34acceptAnsiColorCodes = (consoleMode & NativeMethodsShared.ENABLE_VIRTUAL_TERMINAL_PROCESSING) != 0; 78if (NativeMethodsShared.IsWindows) 81IntPtr stdHandle = NativeMethodsShared.GetStdHandle(NativeMethodsShared.STD_OUTPUT_HANDLE); 85uint fileType = NativeMethodsShared.GetFileType(stdHandle); 88isScreen = fileType == NativeMethodsShared.FILE_TYPE_CHAR;
Logging\SimpleErrorLogger.cs (4)
27(acceptAnsiColorCodes, _, originalConsoleMode) = NativeMethods.QueryIsScreenAndTryEnableAnsiColorCodes(NativeMethods.StreamHandleType.StdErr); 88NativeMethods.RestoreConsoleMode(originalConsoleMode, NativeMethods.StreamHandleType.StdErr);
ManagedFileSystem.cs (1)
26return NativeMethodsShared.IsWindows;
Modifiers.cs (1)
464if (NativeMethodsShared.IsWindows)
MSBuildNameIgnoreCaseComparer.cs (6)
25private static readonly NativeMethodsShared.ProcessorArchitectures s_runningProcessorArchitecture = NativeMethodsShared.ProcessorArchitecture; 72if ((s_runningProcessorArchitecture != NativeMethodsShared.ProcessorArchitectures.IA64) 73&& (s_runningProcessorArchitecture != NativeMethodsShared.ProcessorArchitectures.ARM)) 119if ((s_runningProcessorArchitecture != NativeMethodsShared.ProcessorArchitectures.IA64) 120&& (s_runningProcessorArchitecture != NativeMethodsShared.ProcessorArchitectures.ARM))
NamedPipeUtil.cs (1)
25if (NativeMethodsShared.IsUnixLike)
TempFileUtilities.cs (6)
42string msbuildTempFolder = NativeMethodsShared.IsWindows ? 48if (NativeMethodsShared.IsLinux && NativeMethodsShared.mkdir(basePath, userRWX) != 0) 50if (NativeMethodsShared.chmod(basePath, userRWX) == 0) 60while (NativeMethodsShared.mkdir(pathToCheck, userRWX) != 0 && NativeMethodsShared.chmod(pathToCheck, userRWX) != 0)
WindowsFileSystem.cs (5)
58return NativeMethodsShared.DirectoryExistsWindows(path); 63return NativeMethodsShared.FileExistsWindows(path); 68return NativeMethodsShared.FileOrDirectoryExistsWindows(path); 73var fileLastWriteTime = NativeMethodsShared.GetLastWriteFileUtcTime(path); 81NativeMethodsShared.GetLastWriteDirectoryUtcTime(path, out var directoryLastWriteTime);
Microsoft.Build.BuildCheck.UnitTests (1)
AssemblyInfo.cs (1)
4global using NativeMethodsShared = Microsoft.Build.Framework.NativeMethods;
Microsoft.Build.CommandLine.UnitTests (15)
AssemblyInfo.cs (1)
4global using NativeMethodsShared = Microsoft.Build.Framework.NativeMethods;
TerminalLogger_Tests.cs (2)
39private readonly string _projectFile = NativeMethods.IsUnixLike ? "/src/project.proj" : @"C:\src\project.proj"; 40private readonly string _projectFile2 = NativeMethods.IsUnixLike ? "/src/project2.proj" : @"C:\src\project2.proj";
XMake_Tests.cs (12)
108parameters[1].ShouldBe(Convert.ToString(NativeMethodsShared.GetLogicalCoreCount())); 1165NativeMethodsShared.IsWindows ? @"c:\bin\msbuild.exe" : "/msbuild.exe", 1192private readonly string _pathToArbitraryBogusFile = NativeMethodsShared.IsWindows // OK on 64 bit as well 1202var msbuildParameters = "\"" + _pathToArbitraryBogusFile + "\"" + (NativeMethodsShared.IsWindows ? " /v:diag" : " -v:diag"); 1208output.ShouldContain(RunnerUtilities.PathToCurrentlyRunningMsBuildExe + (NativeMethodsShared.IsWindows ? " /v:diag " : " -v:diag ") + _pathToArbitraryBogusFile, Case.Insensitive); 1217var msbuildParameters = "\"" + _pathToArbitraryBogusFile + "\"" + (NativeMethodsShared.IsWindows ? " /v:diag" : " -v:diag"); 1223if (NativeMethodsShared.IsWindows) 1231output.ShouldContain(RunnerUtilities.PathToCurrentlyRunningMsBuildExe + (NativeMethodsShared.IsWindows ? " /v:diag " : " -v:diag ") + _pathToArbitraryBogusFile, Case.Insensitive); 1247var msbuildParameters = "\"" + _pathToArbitraryBogusFile + "\"" + (NativeMethodsShared.IsWindows ? " /v:diag" : " -v:diag"); 1257output.ShouldContain(RunnerUtilities.PathToCurrentlyRunningMsBuildExe + (NativeMethodsShared.IsWindows ? " /v:diag " : " -v:diag ") + _pathToArbitraryBogusFile, Case.Insensitive); 2120fileLoggerParameters = new[] { "Parameter1", "verbosity=Normal;logfile=" + (NativeMethodsShared.IsWindows ? "c:\\temp\\cat.log" : "/tmp/cat.log") }; 2611ProjectCollection.DisplayVersion, NativeMethodsShared.FrameworkName);
Microsoft.Build.Engine.OM.UnitTests (71)
AssemblyInfo.cs (1)
4global using NativeMethodsShared = Microsoft.Build.Framework.NativeMethods;
BuildEnvironmentHelper.cs (12)
139if (!NativeMethodsShared.IsWindows) 171if (NativeMethodsShared.IsWindows && 244if (NativeMethodsShared.IsWindows && 374NativeMethodsShared.ProcessorArchitecture == Framework.NativeMethods.ProcessorArchitectures.X64 ? "amd64" : 375NativeMethodsShared.ProcessorArchitecture == Framework.NativeMethods.ProcessorArchitectures.ARM64 ? "arm64" : string.Empty, 580MSBuildToolsDirectoryRoot = NativeMethodsShared.ProcessorArchitecture switch 582NativeMethodsShared.ProcessorArchitectures.X86 => CurrentMSBuildToolsDirectory, 583NativeMethodsShared.ProcessorArchitectures.X64 or NativeMethodsShared.ProcessorArchitectures.ARM64 585_ => throw new InternalErrorException("Unknown processor architecture " + NativeMethodsShared.ProcessorArchitecture),
Construction\ProjectRootElement_Tests.cs (1)
1759Assert.Equal(NativeMethodsShared.GetCurrentDirectory(), rootElement.DirectoryPath);
Construction\WhiteSpacePreservation_Tests.cs (1)
449if (NativeMethodsShared.IsWindows)
Definition\DefinitionEditing_Tests.cs (9)
331NativeMethodsShared.IsWindows 524NativeMethodsShared.IsWindows ? @"c:\subdir1\**\subdir2\**\*.x?x" : "/subdir1/**/subdir2/**/*.x?x"); 530NativeMethodsShared.IsWindows ? @"c:\subdir1\a\b\subdir2\c\i1.xyx" : "/subdir1/a/b/subdir2/c/i1.xyx")[ 534NativeMethodsShared.IsWindows ? 1520xml.AddImport(NativeMethodsShared.IsWindows ? 2249NativeMethodsShared.IsWindows ? @"c:\" + Guid.NewGuid().ToString() + @"\**\i1" : "/" + Guid.NewGuid().ToString() + "/**/i1"); 2439NativeMethodsShared.IsWindows ? @"c:\subdir1\**\subdir2\**\*.x?x" : "/subdir1/**/subdir2/**/*.x?x"); 2443NativeMethodsShared.IsWindows ? @"c:\subdir1\a\b\subdir2\c\i1.xyx" : "/subdir1/a/b/subdir2/c/i1.xyx")[0].Xml; 2446NativeMethodsShared.IsWindows ?
Definition\Project_Tests.cs (3)
44private readonly int RootPrefixLength = NativeMethodsShared.IsWindows ? 3 : 1; 676if (NativeMethodsShared.IsWindows) 2802var itemElements = NativeMethodsShared.GetLogicalCoreCount() * 5;
Definition\ProjectCollection_Tests.cs (1)
409string projectDirectory = NativeMethodsShared.IsWindows ? "c:\\1" : "/l";
Definition\ProjectItem_Tests.cs (12)
285NativeMethodsShared.IsWindows ? @"<i Include='c:\foo\bar.baz'/>" : @"<i Include='/foo/bar.baz'/>"); 299NativeMethodsShared.IsWindows ? @"c:\foo\bar.baz" : "/foo/bar.baz", 301Assert.Equal(NativeMethodsShared.IsWindows ? @"c:\" : "/", item.GetMetadataValue("RootDir")); 304Assert.Equal(NativeMethodsShared.IsWindows ? @"c:\foo\" : "/foo/", item.GetMetadataValue("RelativeDir")); 305Assert.Equal(NativeMethodsShared.IsWindows ? @"foo\" : "foo/", item.GetMetadataValue("Directory")); 308NativeMethodsShared.IsWindows ? @"c:\foo\bar.baz" : "/foo/bar.baz", 370"<i Include='" + directory + (NativeMethodsShared.IsWindows ? @"\**\*'/>" : "/**/*'/>")); 372Assert.Equal(NativeMethodsShared.IsWindows ? @"b\" : "b/", item.GetMetadataValue("RecursiveDir")); 415IList<ProjectItem> items = ObjectModelHelpers.GetItemsFromFragment("<i Include='i0;" + directory + (NativeMethodsShared.IsWindows ? @"\**\*;i2'/>" : "/**/*;i2'/>")); 419Assert.Equal(NativeMethodsShared.IsWindows ? @"b\" : "b/", items[1].GetMetadataValue("RecursiveDir")); 752if (NativeMethodsShared.IsWindows) 1646<i Include='i1.cpp;" + (NativeMethodsShared.IsWindows ? @"c:\bar\i2.cpp" : "/bar/i2.cpp") + @"'>
Definition\ProjectItemDefinition_Tests.cs (4)
240<i Include='" + (NativeMethodsShared.IsWindows ? @"c:\a\b.ext" : "/a/b.ext") + @"'/> 266<i Include='" + (NativeMethodsShared.IsWindows ? @"c:\a\b.ext" : "/a/b.ext") + @"'/> 292<i Include='" + (NativeMethodsShared.IsWindows ? @"c:\a\b.ext" : "/a/b.ext") + @"'/> 320<i Include='" + (NativeMethodsShared.IsWindows ? @"c:\a\b.ext" : "/a/b.ext") + @"'>
Definition\ProjectProperty_Tests.cs (2)
155string varName = NativeMethodsShared.IsWindows ? "username" : "USER"; 178string varName = NativeMethodsShared.IsWindows ? "username" : "USER";
FileSystems.cs (1)
20if (NativeMethodsShared.IsWindows)
FileUtilities.cs (9)
160if (NativeMethodsShared.GetLastWriteDirectoryUtcTime(directoryPath, out lastModifiedTime)) 564if (NativeMethodsShared.IsWindows || string.IsNullOrEmpty(value) 585if (NativeMethodsShared.IsWindows || value.IsEmpty) 670if (NativeMethodsShared.IsWindows) 764if (NativeMethodsShared.IsWindows && !EndsWithSlash(fullPath)) 1205return path.Length >= NativeMethodsShared.MaxPath; 1210bool hasMaxPath = NativeMethodsShared.HasMaxPath; 1211int maxPath = NativeMethodsShared.MaxPath; 1213return hasMaxPath && !IsRootedNoThrow(path) && NativeMethodsShared.GetCurrentDirectory().Length + path.Length + 1 /* slash */ >= maxPath;
Instance\ProjectInstance_Tests.cs (3)
895instance.GetProperty(NativeMethodsShared.IsWindows ? "username" : "USER").EvaluatedValue = 920instance.GetProperty(NativeMethodsShared.IsWindows ? "username" : "USER").EvaluatedValue = 942instance.GetProperty(NativeMethodsShared.IsWindows ? "username" : "USER").EvaluatedValue =
Instance\ProjectItemInstance_Tests.cs (1)
757<i Include='i1.cpp;" + (NativeMethodsShared.IsWindows ? @"c:\bar\i2.cpp" : "/bar/i2.cpp") + @"'>
TempFileUtilities.cs (6)
42string msbuildTempFolder = NativeMethodsShared.IsWindows ? 48if (NativeMethodsShared.IsLinux && NativeMethodsShared.mkdir(basePath, userRWX) != 0) 50if (NativeMethodsShared.chmod(basePath, userRWX) == 0) 60while (NativeMethodsShared.mkdir(pathToCheck, userRWX) != 0 && NativeMethodsShared.chmod(pathToCheck, userRWX) != 0)
WindowsFileSystem.cs (5)
58return NativeMethodsShared.DirectoryExistsWindows(path); 63return NativeMethodsShared.FileExistsWindows(path); 68return NativeMethodsShared.FileOrDirectoryExistsWindows(path); 73var fileLastWriteTime = NativeMethodsShared.GetLastWriteFileUtcTime(path); 81NativeMethodsShared.GetLastWriteDirectoryUtcTime(path, out var directoryLastWriteTime);
Microsoft.Build.Engine.UnitTests (151)
AssemblyInfo.cs (1)
4global using NativeMethodsShared = Microsoft.Build.Framework.NativeMethods;
BackEnd\BuildManager_Tests.cs (1)
3971MaxNodeCount = NativeMethodsShared.GetLogicalCoreCount(),
BackEnd\BuildRequestConfiguration_Tests.cs (1)
535if (!NativeMethodsShared.IsWindows)
BackEnd\TargetUpToDateChecker_Tests.cs (6)
1002NativeMethodsShared.CreateFile( 1003inputSymlink, NativeMethodsShared.GENERIC_READ | 0x100 /* FILE_WRITE_ATTRIBUTES */, 1004NativeMethodsShared.FILE_SHARE_READ, IntPtr.Zero, NativeMethodsShared.OPEN_EXISTING, 1005NativeMethodsShared.FILE_ATTRIBUTE_NORMAL | NativeMethodsShared.FILE_FLAG_OPEN_REPARSE_POINT,
BinaryLogger_Tests.cs (2)
484Assert.True(NativeMethodsShared.MakeSymbolicLink(symlinkPath, testFile.Path, ref errorMessage), errorMessage); 485Assert.True(NativeMethodsShared.MakeSymbolicLink(symlinkLvl2Path, symlinkPath, ref errorMessage), errorMessage);
ConsoleLogger_Tests.cs (5)
2381bool runningWithCharDevice = NativeMethodsShared.IsWindows ? IsRunningWithCharacterFileType() : false; 2462IntPtr stdHandle = NativeMethodsShared.GetStdHandle(NativeMethodsShared.STD_OUTPUT_HANDLE); 2466uint fileType = NativeMethodsShared.GetFileType(stdHandle); 2469return fileType == NativeMethodsShared.FILE_TYPE_CHAR;
Construction\SolutionFile_Tests.cs (5)
35p.FullPath = NativeMethodsShared.IsWindows ? "c:\\foo.sln" : "/foo.sln"; 76p.FullPath = NativeMethodsShared.IsWindows ? "c:\\foo.sln" : "/foo.sln"; 95p.FullPath = NativeMethodsShared.IsWindows ? "c:\\foo.sln" : "/foo.sln"; 115p.FullPath = NativeMethodsShared.IsWindows ? "c:\\foo.sln" : "/foo.sln"; 678p.FullPath = NativeMethodsShared.IsWindows ? "c:\\foo.sln" : "/foo.sln";
Definition\Toolset_Tests.cs (2)
55if (NativeMethodsShared.IsWindows) 230if (NativeMethodsShared.IsUnixLike)
Definition\ToolsetConfigurationReader_Tests.cs (2)
567if (NativeMethodsShared.IsWindows) 572else if (NativeMethodsShared.IsOSX)
Definition\ToolsVersion_Tests.cs (18)
33string dir = NativeMethodsShared.IsWindows ? "c:\\directory1\\directory2" : "/directory1/directory2"; 34string overrideDir = NativeMethodsShared.IsWindows ? "c:\\msbuildoverridetasks" : "/msbuildoverridetasks"; 148NativeMethodsShared.IsWindows ? "c:\\directory1\\directory2" : "/directory1/directory2", 224string dir = NativeMethodsShared.IsWindows ? "c:\\directory1\\directory2" : "/directory1/directory2"; 225string overrideDir = NativeMethodsShared.IsWindows ? "c:\\msbuildoverridetasks" : "/msbuildoverridetasks"; 889NativeMethodsShared.IsWindows ? "c:\\inline" : "/inline", 954new DefaultTasksFile(NativeMethodsShared.IsWindows 963new DefaultTasksFile(NativeMethodsShared.IsWindows 969new DefaultTasksFile(NativeMethodsShared.IsWindows 975new DefaultTasksFile(NativeMethodsShared.IsWindows 981new DefaultTasksFile(NativeMethodsShared.IsWindows 987new DefaultTasksFile(NativeMethodsShared.IsWindows 993new DefaultTasksFile(NativeMethodsShared.IsWindows 1001new DefaultTasksFile(NativeMethodsShared.IsWindows 1009new DefaultTasksFile(NativeMethodsShared.IsWindows 1015new DefaultTasksFile(NativeMethodsShared.IsWindows 1028new DefaultTasksFile(NativeMethodsShared.IsWindows 1037new DefaultTasksFile(NativeMethodsShared.IsWindows
Evaluation\Evaluator_Tests.cs (13)
122string fooPath = NativeMethodsShared.IsWindows ? @"c:\temp\foo.import" : "/temp/foo.import"; 123string barPath = NativeMethodsShared.IsWindows ? @"c:\temp\bar.import" : "/temp/bar.import"; 1301string targets1FileName = NativeMethodsShared.IsWindows ? @"c:\a\t1.targets" : "/a/t1.targets"; 1302string aDirName = NativeMethodsShared.IsWindows ? @"c:\a\" : "/a/"; 1303string targets2FileName = NativeMethodsShared.IsWindows ? @"c:\a\b\t2.targets" : "/a/b/t2.targets"; 1304string bDirName = NativeMethodsShared.IsWindows ? @"c:\a\b\" : "/a/b/"; 1305string targets3FileName = NativeMethodsShared.IsWindows ? @"c:\t3.targets" : "/t3.targets"; 1306string rootDirName = NativeMethodsShared.IsWindows ? @"c:\" : "/"; 1307string aProjName = NativeMethodsShared.IsWindows ? @"c:\a\p.proj" : "/a/p.proj"; 2702string file = NativeMethodsShared.IsWindows ? @"c:\foo\bar.csproj" : "/foo/bar.csproj"; 2721string file = NativeMethodsShared.IsWindows ? @"c:\bar.csproj" : "/bar.csproj"; 2722string dir = NativeMethodsShared.IsWindows ? @"c:\" : "/"; 3746if (NativeMethodsShared.IsUnixLike)
Evaluation\Expander_Tests.cs (10)
41private static readonly string s_rootPathPrefix = NativeMethodsShared.IsWindows ? "C:\\" : Path.VolumeSeparatorChar.ToString(); 1315NativeMethodsShared.IsWindows ? @"subdir1\engine.dll" : "subdir1/engine.dll", project.FullPath); 1319NativeMethodsShared.IsWindows ? @"subdir2\tasks.dll" : "subdir2/tasks.dll", project.FullPath); 1805string envVar = NativeMethodsShared.IsWindows ? "TEMP" : "USER"; 3760string envVar = NativeMethodsShared.IsWindows ? "TEMP" : "USER"; 3784string envVar = NativeMethodsShared.IsWindows ? "TEMP" : "USER"; 3808string envVar = NativeMethodsShared.IsWindows ? "TEMP" : "USER"; 3832string envVar = NativeMethodsShared.IsWindows ? "TEMP" : "USER"; 4228if (NativeMethodsShared.IsWindows) 4233if (!NativeMethodsShared.IsWindows)
Evaluation\ImportFromMSBuildExtensionsPath_Tests.cs (7)
471<searchPaths os=""" + NativeMethodsShared.GetOSNameForExtensionsPath() + @"""> 553<searchPaths os=""" + NativeMethodsShared.GetOSNameForExtensionsPath() + @"""> 614<searchPaths os=""" + NativeMethodsShared.GetOSNameForExtensionsPath() + @"""> 684<searchPaths os=""" + NativeMethodsShared.GetOSNameForExtensionsPath() + @"""> 750<searchPaths os=""" + NativeMethodsShared.GetOSNameForExtensionsPath() + @"""> 817<searchPaths os=""" + NativeMethodsShared.GetOSNameForExtensionsPath() + @"""> 962<searchPaths os=""" + NativeMethodsShared.GetOSNameForExtensionsPath() + @""">
Evaluation\ItemEvaluation_Tests.cs (1)
604if (!NativeMethodsShared.IsWindows)
Evaluation\ItemSpec_Tests.cs (1)
42var absoluteRootPath = NativeMethodsShared.IsWindows
Evaluation\ProjectRootElementCache_Tests.cs (2)
72string rootedPath = NativeMethodsShared.IsUnixLike ? "/foo" : "c:\\foo"; 85string projectPath = NativeMethodsShared.IsUnixLike ? "/foo" : "c:\\foo";
Evaluation\SimpleProjectRootElementCache_Tests.cs (11)
33string projectFile = NativeMethodsShared.IsUnixLike ? "/foo" : "c:\\foo"; 34string projectFileToCache = NativeMethodsShared.IsUnixLike ? "/foo" : "c:\\foo"; 47string projectFile = NativeMethodsShared.IsUnixLike ? "/foo" : "c:\\foo"; 48string projectFileToCache = NativeMethodsShared.IsUnixLike ? "/Foo" : "c:\\Foo"; 61string projectFile = NativeMethodsShared.IsUnixLike ? "/foo" : "c:\\foo"; 62string projectFileToCache = NativeMethodsShared.IsUnixLike ? "/foo" : "c:\\foo"; 79string projectFile = NativeMethodsShared.IsUnixLike ? "/foo" : "c:\\foo"; 80string projectFileToCache = NativeMethodsShared.IsUnixLike ? "/Foo" : "c:\\Foo"; 97string projectFile = NativeMethodsShared.IsUnixLike ? "/foo" : "c:\\foo"; 111string projectFile = NativeMethodsShared.IsUnixLike ? "/foo" : "c:\\foo"; 112string projectFileToCache = NativeMethodsShared.IsUnixLike ? "/bar" : "c:\\bar";
FileMatcher_Tests.cs (29)
159if (!NativeMethodsShared.IsLinux) 263ExpectNoMatches = NativeMethodsShared.IsLinux 285ExpectNoMatches = NativeMethodsShared.IsLinux, 303ExpectNoMatches = NativeMethodsShared.IsLinux, 324ExpectNoMatches = NativeMethodsShared.IsLinux, 343ExpectNoMatches = NativeMethodsShared.IsLinux, 360ExpectNoMatches = NativeMethodsShared.IsLinux, 452ExpectNoMatches = NativeMethodsShared.IsLinux, 476ExpectNoMatches = NativeMethodsShared.IsLinux, 498ExpectNoMatches = NativeMethodsShared.IsLinux, 514ExpectNoMatches = NativeMethodsShared.IsLinux, 1004if (NativeMethodsShared.IsWindows) 1018NativeMethodsShared.IsWindows ? "f:\\dir1\\dir2\\file.txt" : "/dir1/dir2/file.txt", 1019NativeMethodsShared.IsWindows ? "f:\\dir1\\dir2\\file.txt" : "/dir1/dir2/file.txt", 1446string[] strings = new string[1] { NativeMethodsShared.IsWindows ? "c:\\1.file" : "/1.file" }; 1447strings = FileMatcher.RemoveProjectDirectory(strings, NativeMethodsShared.IsWindows ? "c:\\" : "/").ToArray(); 1450strings = new string[1] { NativeMethodsShared.IsWindows ? "c:\\directory\\1.file" : "/directory/1.file" }; 1451strings = FileMatcher.RemoveProjectDirectory(strings, NativeMethodsShared.IsWindows ? "c:\\" : "/").ToArray(); 1452Assert.Equal(strings[0], NativeMethodsShared.IsWindows ? "directory\\1.file" : "directory/1.file"); 1454strings = new string[1] { NativeMethodsShared.IsWindows ? "c:\\directory\\1.file" : "/directory/1.file" }; 1455strings = FileMatcher.RemoveProjectDirectory(strings, NativeMethodsShared.IsWindows ? "c:\\directory" : "/directory").ToArray(); 1458strings = new string[1] { NativeMethodsShared.IsWindows ? "c:\\1.file" : "/1.file" }; 1459strings = FileMatcher.RemoveProjectDirectory(strings, NativeMethodsShared.IsWindows ? "c:\\directory" : "/directory").ToArray(); 1460Assert.Equal(strings[0], NativeMethodsShared.IsWindows ? "c:\\1.file" : "/1.file"); 1462strings = new string[1] { NativeMethodsShared.IsWindows ? "c:\\directorymorechars\\1.file" : "/directorymorechars/1.file" }; 1463strings = FileMatcher.RemoveProjectDirectory(strings, NativeMethodsShared.IsWindows ? "c:\\directory" : "/directory").ToArray(); 1464Assert.Equal(strings[0], NativeMethodsShared.IsWindows ? "c:\\directorymorechars\\1.file" : "/directorymorechars/1.file"); 1466if (NativeMethodsShared.IsWindows) 1849if (NativeMethodsShared.IsUnixLike)
FileUtilities_Tests.cs (13)
51string itemSpec = NativeMethodsShared.IsWindows ? @"c:\foo.txt" : "/foo.txt"; 52string itemSpecDir = NativeMethodsShared.IsWindows ? @"c:\" : "/"; 72string projectPath = NativeMethodsShared.IsWindows ? @"c:\abc\goo.proj" : @"/abc/goo.proj"; 73string projectPathDir = NativeMethodsShared.IsWindows ? @"c:\abc\" : @"/abc/"; 90if (NativeMethodsShared.IsWindows) 246Assert.Equal(NativeMethodsShared.IsWindows ? @"c:\" : "/", FileUtilities.GetDirectory(NativeMethodsShared.IsWindows ? @"c:\" : "/")); 247Assert.Equal(NativeMethodsShared.IsWindows ? @"c:\" : "/", FileUtilities.GetDirectory(NativeMethodsShared.IsWindows ? @"c:\foo" : "/foo")); 248Assert.Equal(NativeMethodsShared.IsWindows ? @"c:" : "/", FileUtilities.GetDirectory(NativeMethodsShared.IsWindows ? @"c:" : "/")); 550var isWindows = NativeMethodsShared.IsWindows; 965string root = NativeMethodsShared.IsWindows ? @"c:\" : "/";
Globbing\MSBuildGlob_Tests.cs (6)
39var globRoot = NativeMethodsShared.IsWindows ? @"c:\a" : "/a"; 112var globRoot = NativeMethodsShared.IsWindows ? @"c:\a" : "/a"; 133var globRoot = NativeMethodsShared.IsWindows ? @"c:\a" : "/a"; 153var globRoot = NativeMethodsShared.IsWindows ? @"c:\a" : "/a"; 206if (NativeMethodsShared.IsUnixLike) 353return NativeMethodsShared.IsWindows ? normalizedPath.Replace("\\\\", "\\") : normalizedPath;
Graph\IsolateProjects_Tests.cs (2)
139if (NativeMethodsShared.IsOSX) 147var disableInProcNode = !NativeMethodsShared.IsOSX;
Graph\ParallelWorkSet_Tests.cs (4)
69DegreeOfParallelism = NativeMethodsShared.GetLogicalCoreCount(), 97DegreeOfParallelism = NativeMethodsShared.GetLogicalCoreCount() 112DegreeOfParallelism = NativeMethodsShared.GetLogicalCoreCount(), 176DegreeOfParallelism = NativeMethodsShared.GetLogicalCoreCount(),
ProjectCache\ProjectCacheTests.cs (8)
663var referenceNumbers = Enumerable.Range(2, NativeMethodsShared.GetLogicalCoreCount()).ToArray(); 1395MaxNodeCount = NativeMethodsShared.GetLogicalCoreCount(), 1451var referenceNumbers = Enumerable.Range(2, NativeMethodsShared.GetLogicalCoreCount() * 2).ToArray(); 1468MaxNodeCount = NativeMethodsShared.GetLogicalCoreCount(), 1514var referenceNumbers = Enumerable.Range(2, NativeMethodsShared.GetLogicalCoreCount() * 2).ToArray(); 1528MaxNodeCount = NativeMethodsShared.GetLogicalCoreCount(), 1578var projectPaths = Enumerable.Range(0, NativeMethodsShared.GetLogicalCoreCount()) 1608MaxNodeCount = NativeMethodsShared.GetLogicalCoreCount()
Utilities_Tests.cs (1)
95'"' + (NativeMethodsShared.IsUnixLike ? "-pp:" : "/pp:") + outputFile.Path + '"'}));
Microsoft.Build.Framework (5)
EncodingUtilities.cs (3)
57if (NativeMethods.IsWindows) 63s_currentOemEncoding = Encoding.GetEncoding(NativeMethods.GetOEMCP()); 223if (!NativeMethods.IsWindows)
NativeMethods.cs (2)
1067bool success = NativeMethods.GetFileAttributesEx(path, 0, ref data); 1069if (success && (data.fileAttributes & NativeMethods.FILE_ATTRIBUTE_DIRECTORY) == 0)
Microsoft.Build.Framework.UnitTests (5)
AssemblyInfo.cs (1)
4global using NativeMethodsShared = Microsoft.Build.Framework.NativeMethods;
FileClassifier_Tests.cs (4)
26var volume = NativeMethodsShared.IsWindows ? @"X:\" : "/home/usr"; 40var volume = NativeMethodsShared.IsWindows ? @"X:\" : "/home/usr"; 58var volume = NativeMethodsShared.IsWindows ? @"X:\" : "/home/usr"; 61if (NativeMethodsShared.IsLinux)
Microsoft.Build.Tasks.Core (128)
AssemblyDependency\AssemblyInformation.cs (9)
78if (NativeMethodsShared.IsWindows) 246if (!NativeMethodsShared.IsWindows) 365if (hr == NativeMethodsShared.S_OK) 384if (!NativeMethodsShared.IsWindows) 637if (NativeMethodsShared.IsWindows) 660if (NativeMethodsShared.IsWindows) 679if (hresult == NativeMethodsShared.ERROR_INSUFFICIENT_BUFFER) 690return hresult == NativeMethodsShared.S_OK ? new string(runtimeVersion, 0, dwLength - 1) : string.Empty; 711if (!NativeMethodsShared.IsWindows)
AssemblyDependency\AssemblyMetadata.cs (1)
30ScatterFiles = NativeMethodsShared.IsWindows ? import.Files : null;
AssemblyDependency\GlobalAssemblyCache.cs (2)
185if (NativeMethodsShared.IsWindows) 189ErrorUtilities.VerifyThrow(hr == NativeMethodsShared.S_OK, "CreateAssemblyCache failed, hr {0}", hr);
AssemblyDependency\Reference.cs (1)
514else if (NativeMethodsShared.IsWindows)
AssemblyDependency\ResolveAssemblyReference.cs (1)
3220p => NativeMethodsShared.GetLastWriteFileUtcTime(p),
AssemblyFolder.cs (1)
108if (NativeMethodsShared.IsWindows)
AssemblyFoldersEx.cs (1)
80if (!NativeMethodsShared.IsWindows)
AssemblyInfo.cs (1)
4global using NativeMethodsShared = Microsoft.Build.Framework.NativeMethods;
BuildEnvironmentHelper.cs (12)
139if (!NativeMethodsShared.IsWindows) 171if (NativeMethodsShared.IsWindows && 244if (NativeMethodsShared.IsWindows && 374NativeMethodsShared.ProcessorArchitecture == Framework.NativeMethods.ProcessorArchitectures.X64 ? "amd64" : 375NativeMethodsShared.ProcessorArchitecture == Framework.NativeMethods.ProcessorArchitectures.ARM64 ? "arm64" : string.Empty, 580MSBuildToolsDirectoryRoot = NativeMethodsShared.ProcessorArchitecture switch 582NativeMethodsShared.ProcessorArchitectures.X86 => CurrentMSBuildToolsDirectory, 583NativeMethodsShared.ProcessorArchitectures.X64 or NativeMethodsShared.ProcessorArchitectures.ARM64 585_ => throw new InternalErrorException("Unknown processor architecture " + NativeMethodsShared.ProcessorArchitecture),
ComReference.cs (6)
383IntPtr libraryHandle = NativeMethodsShared.LoadLibrary(typeLibPath); 392NativeMethodsShared.FreeLibrary(libraryHandle); 409for (int bufferSize = NativeMethodsShared.MAX_PATH; bufferSize <= NativeMethodsShared.MaxPath; bufferSize *= 2) 415int pathLength = NativeMethodsShared.GetModuleFileName(handleRef, buffer, bufferSize); 417bool isBufferTooSmall = (uint)Marshal.GetLastWin32Error() == NativeMethodsShared.ERROR_INSUFFICIENT_BUFFER;
Copy.cs (4)
46private static readonly int DefaultCopyParallelism = NativeMethodsShared.GetLogicalCoreCount() > 4 ? 6 : 4; 323TryCopyViaLink(SymbolicLinkComment, MessageImportance.Normal, sourceFileState, destinationFileState, out symbolicLinkCreated, ref errorMessage, (source, destination, errMessage) => NativeMethodsShared.MakeSymbolicLink(destination, source, ref errorMessage)); 326if (!NativeMethodsShared.IsWindows) 1028if (NativeMethodsShared.IsWindows)
Exec.cs (7)
73if (NativeMethodsShared.IsUnixLike) 210if (!NativeMethodsShared.IsUnixLike) 255if (!NativeMethodsShared.IsUnixLike) 493if (NativeMethodsShared.IsWindows) 570if (NativeMethodsShared.IsUnixLike) 585if (NativeMethodsShared.IsWindows) 646protected override string ToolName => NativeMethodsShared.IsWindows ? "cmd.exe" : "sh";
FileMatcher.cs (5)
1053if (NativeMethodsShared.IsLinux && recursionState.SearchData.DirectoryPattern != null) 1194using (var matchFileExpression = new ReuseableStringBuilder(FileSpecRegexMinLength + NativeMethodsShared.MAX_PATH)) 1259bool isUncPath = NativeMethodsShared.IsWindows && fixedDir.Length > 1 2255if (NativeMethodsShared.IsWindows && 2576var maxTasks = Math.Max(1, NativeMethodsShared.GetLogicalCoreCount() / 2);
FileState.cs (11)
90if (NativeMethodsShared.IsWindows) 98NativeMethodsShared.SetThreadErrorMode(1 /* ErrorModes.SEM_FAILCRITICALERRORS */, out oldMode); 103if (NativeMethodsShared.IsWindows) 105var data = new NativeMethodsShared.WIN32_FILE_ATTRIBUTE_DATA(); 106bool success = NativeMethodsShared.GetFileAttributesEx(_filename, 0, ref data); 119&& _filename.Length <= NativeMethodsShared.MaxPath) 129NativeMethodsShared.ThrowExceptionForErrorCode(error); 134IsDirectory = (data.fileAttributes & NativeMethodsShared.FILE_ATTRIBUTE_DIRECTORY) != 0; 136&& (data.fileAttributes & NativeMethodsShared.FILE_ATTRIBUTE_READONLY) != 0; 177if (NativeMethodsShared.IsWindows) 179NativeMethodsShared.SetThreadErrorMode(oldMode, out _);
FileSystems.cs (1)
20if (NativeMethodsShared.IsWindows)
FileUtilities.cs (13)
160if (NativeMethodsShared.GetLastWriteDirectoryUtcTime(directoryPath, out lastModifiedTime)) 484if (NativeMethodsShared.IsWindows) 486string uncheckedFullPath = NativeMethodsShared.GetFullPath(path); 490string message = ResourceUtilities.FormatString(AssemblyResources.GetString("Shared.PathTooLong"), path, NativeMethodsShared.MaxPath); 509if (!NativeMethodsShared.IsWindows || !path.StartsWith(@"\\", StringComparison.Ordinal)) 564if (NativeMethodsShared.IsWindows || string.IsNullOrEmpty(value) 585if (NativeMethodsShared.IsWindows || value.IsEmpty) 670if (NativeMethodsShared.IsWindows) 764if (NativeMethodsShared.IsWindows && !EndsWithSlash(fullPath)) 1205return path.Length >= NativeMethodsShared.MaxPath; 1210bool hasMaxPath = NativeMethodsShared.HasMaxPath; 1211int maxPath = NativeMethodsShared.MaxPath; 1213return hasMaxPath && !IsRootedNoThrow(path) && NativeMethodsShared.GetCurrentDirectory().Length + path.Length + 1 /* slash */ >= maxPath;
GenerateApplicationManifest.cs (1)
115if (!NativeMethodsShared.IsWindows)
GenerateDeploymentManifest.cs (1)
157if (!NativeMethodsShared.IsWindows)
GenerateLauncher.cs (1)
44if (!NativeMethodsShared.IsWindows)
GenerateManifestBase.cs (2)
275if (!NativeMethodsShared.IsWindows) 623if (NativeMethodsShared.IsWindows)
GenerateResource.cs (9)
932private static readonly bool AllowMOTW = !NativeMethodsShared.IsWindows || (Registry.GetValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework\SDK", "AllowProcessOfUntrustedResourceFiles", null) is string allowUntrustedFiles && allowUntrustedFiles.Equals("true", StringComparison.OrdinalIgnoreCase)); 1155if (!_resgenPath.Equals(Path.GetDirectoryName(NativeMethodsShared.GetLongFilePath(ToolLocationHelper.GetPathToDotNetFrameworkSdkFile("resgen.exe", TargetDotNetFrameworkVersion.Version35))), StringComparison.OrdinalIgnoreCase)) 1510DateTime outputTime = NativeMethodsShared.GetLastWriteFileUtcTime(outputFilePath); 1520DateTime sourceTime = NativeMethodsShared.GetLastWriteFileUtcTime(sourceFilePath); 1566DateTime linkedFileTime = NativeMethodsShared.GetLastWriteFileUtcTime(linkedFilePath); 1653DateTime sourceTime = NativeMethodsShared.GetLastWriteFileUtcTime(Sources[0].ItemSpec); 1654DateTime outputTime = NativeMethodsShared.GetLastWriteFileUtcTime(StronglyTypedFileName); 1712DateTime time = NativeMethodsShared.GetLastWriteFileUtcTime(input.ItemSpec); 2830if (!NativeMethodsShared.HasMaxPath)
GetInstalledSDKLocations.cs (1)
127if (!NativeMethodsShared.IsWindows)
GetSDKReferenceFiles.cs (1)
230if (!NativeMethodsShared.IsWindows)
ManagedFileSystem.cs (1)
26return NativeMethodsShared.IsWindows;
ManifestUtil\SecurityUtil.cs (1)
868if (NativeMethodsShared.IsWindows && (toolPath == null || !FileSystems.Default.FileExists(toolPath)))
Modifiers.cs (1)
464if (NativeMethodsShared.IsWindows)
MSBuildNameIgnoreCaseComparer.cs (6)
25private static readonly NativeMethodsShared.ProcessorArchitectures s_runningProcessorArchitecture = NativeMethodsShared.ProcessorArchitecture; 72if ((s_runningProcessorArchitecture != NativeMethodsShared.ProcessorArchitectures.IA64) 73&& (s_runningProcessorArchitecture != NativeMethodsShared.ProcessorArchitectures.ARM)) 119if ((s_runningProcessorArchitecture != NativeMethodsShared.ProcessorArchitectures.IA64) 120&& (s_runningProcessorArchitecture != NativeMethodsShared.ProcessorArchitectures.ARM))
NativeMethods.cs (6)
805if (NativeMethodsShared.IsWindows) 838if (NativeMethodsShared.IsWindows) 989if (NativeMethodsShared.IsWindows) 1243private static readonly string s_gacPath = Path.Combine(NativeMethodsShared.FrameworkBasePath, "gac"); 1284if (NativeMethodsShared.IsWindows) 1344if (NativeMethodsShared.IsWindows)
ResGen.cs (4)
334&& NativeMethodsShared.IsWindows 374NativeMethodsShared.IsWindows && 375!pathToResGen.Equals(NativeMethodsShared.GetLongFilePath(ToolLocationHelper.GetPathToDotNetFrameworkSdkFile("resgen.exe", TargetDotNetFrameworkVersion.Version35)), StringComparison.OrdinalIgnoreCase) && 527pathToTool = NativeMethodsShared.GetLongFilePath(pathToTool);
ResolveSDKReference.cs (1)
268if (!NativeMethodsShared.IsWindows)
SignFile.cs (1)
46if (!NativeMethodsShared.IsWindows)
SystemState.cs (1)
673return lastModified != DateTime.MinValue && lastModified != NativeMethodsShared.MinFileDate;
TempFileUtilities.cs (6)
42string msbuildTempFolder = NativeMethodsShared.IsWindows ? 48if (NativeMethodsShared.IsLinux && NativeMethodsShared.mkdir(basePath, userRWX) != 0) 50if (NativeMethodsShared.chmod(basePath, userRWX) == 0) 60while (NativeMethodsShared.mkdir(pathToCheck, userRWX) != 0 && NativeMethodsShared.chmod(pathToCheck, userRWX) != 0)
WindowsFileSystem.cs (5)
58return NativeMethodsShared.DirectoryExistsWindows(path); 63return NativeMethodsShared.FileExistsWindows(path); 68return NativeMethodsShared.FileOrDirectoryExistsWindows(path); 73var fileLastWriteTime = NativeMethodsShared.GetLastWriteFileUtcTime(path); 81NativeMethodsShared.GetLastWriteDirectoryUtcTime(path, out var directoryLastWriteTime);
WinMDExp.cs (2)
269var outputWriteTime = NativeMethodsShared.GetLastWriteFileUtcTime(OutputWindowsMetadataFile); 270var winMDModuleWriteTime = NativeMethodsShared.GetLastWriteFileUtcTime(WinMDModule);
XamlTaskFactory\TaskParser.cs (1)
174if (NativeMethodsShared.IsWindows)
Microsoft.Build.Tasks.UnitTests (91)
AssemblyDependency\ResolveAssemblyReferenceTestFixture.cs (1)
190protected static readonly string s_rootPathPrefix = NativeMethodsShared.IsWindows ? "C:\\" : Path.VolumeSeparatorChar.ToString();
AssemblyInfo.cs (1)
4global using NativeMethodsShared = Microsoft.Build.Framework.NativeMethods;
AssignLinkMetadata_Tests.cs (1)
137var item = GetParentedTaskItem(NativeMethodsShared.IsUnixLike
AssignTargetPath_Tests.cs (12)
24{ new TaskItem(NativeMethodsShared.IsWindows ? @"c:\bin2\abc.efg" : "/bin2/abc.efg") }; 25t.RootFolder = NativeMethodsShared.IsWindows ? @"c:\bin" : "/bin"; 29t.AssignedFiles[0].ItemSpec.ShouldBe(NativeMethodsShared.IsWindows ? @"c:\bin2\abc.efg" : "/bin2/abc.efg"); 39{ new TaskItem(NativeMethodsShared.IsWindows ? @"c:\f1\f2\file.txt" : "/f1/f2/file.txt") }; 40t.RootFolder = NativeMethodsShared.IsWindows ? @"c:\f1\f2" : "/f1/f2"; 55NativeMethodsShared.IsWindows ? @"d:\f1\f2\f3\f4\file.txt" : "/f1/f2/f3/f4/file.txt") 61t.RootFolder = NativeMethodsShared.IsWindows ? @"c:\f1" : "/x1"; 76NativeMethodsShared.IsWindows ? @"c:\f1\f2\f3\f4\file.txt" : "/f1/f2/f3/f4/file.txt") 78t.RootFolder = NativeMethodsShared.IsWindows ? @"c:\f1\f2" : "/f1/f2"; 82t.AssignedFiles[0].GetMetadata("TargetPath").ShouldBe(NativeMethodsShared.IsWindows ? @"f3\f4\file.txt" : "f3/f4/file.txt"); 101itemSpec: NativeMethodsShared.IsWindows ? @"c:\f1\f2\file.txt" : "/f1/f2/file.txt", 104t.RootFolder = NativeMethodsShared.IsWindows ? @"c:\f1\f2" : "/f1/f2";
CodeTaskFactoryEmbeddedFileInBinlogTestHelper.cs (2)
72projectDirectoryPath = NativeMethodsShared.IsWindows ? projectDirectoryPath.Replace(":\\", "\\") : projectDirectoryPath.Replace("/", "\\"); 124projectDirectory = NativeMethodsShared.IsWindows ? projectDirectory.Replace(":\\", "\\") : projectDirectory.Replace("/", "\\");
CombinePath_Tests.cs (11)
49string path1 = NativeMethodsShared.IsWindows ? @"c:\ghi.txt" : "/ghi.txt"; 50string path2 = NativeMethodsShared.IsWindows ? @"d:\jkl\mno.txt" : "/jkl/mno.txt"; 52string pathsToMatch = string.Format(NativeMethodsShared.IsWindows ? @" 61t.Paths = NativeMethodsShared.IsWindows 78t.BasePath = NativeMethodsShared.IsWindows ? @"c:\abc\def" : "/abc/def"; 98t.BasePath = NativeMethodsShared.IsWindows ? @"\\fileserver\public" : "/rootdir/public"; 99string path1 = NativeMethodsShared.IsWindows ? @"c:\ghi.txt" : "/ghi.txt"; 100string path2 = NativeMethodsShared.IsWindows ? @"d:\jkl\mno.txt" : "/jkl/mno.txt"; 102string pathsToMatch = string.Format(NativeMethodsShared.IsWindows ? @" 110t.Paths = NativeMethodsShared.IsWindows 128if (NativeMethodsShared.IsWindows)
Copy_Tests.cs (5)
1134(!NativeMethodsShared.IsLinux || isUseHardLinks); 1384if (NativeMethodsShared.IsWindows) 1786string invalidFile = NativeMethodsShared.IsUnixLike ? Path.Combine(temp, "!@#$%^&*()|") : "!@#$%^&*()|"; 1817Assert.False(NativeMethodsShared.IsUnixLike ? !success : success); 1823if (NativeMethodsShared.IsUnixLike)
Exec_Tests.cs (26)
148Exec exec = PrepareExec(NativeMethodsShared.IsWindows ? "xcopy thisisanonexistentfile" : "cp thisisanonexistentfile thatisanonexistentfile"); 152Assert.Equal(NativeMethodsShared.IsWindows ? 4 : 1, exec.ExitCode); 154if (!NativeMethodsShared.IsWindows) 164int expectedExitCode = NativeMethodsShared.IsWindows ? -1 : 137; 166Exec exec = PrepareExec(NativeMethodsShared.IsWindows ? ":foo \n goto foo" : "while true; do sleep 1; done"); 185Exec exec = PrepareExec(NativeMethodsShared.IsWindows ? ":foo \n goto foo" : "while true; do sleep 1; done"); 199exec.ExitCode.ShouldBe(NativeMethodsShared.IsWindows ? -1 : 137); 228var cmdLine = NativeMethodsShared.IsWindows 245var cmdLine = NativeMethodsShared.IsWindows 269Exec exec = PrepareExec(NativeMethodsShared.IsWindows ? "echo [%cd%]" : "echo [$PWD]"); 270string working = !NativeMethodsShared.IsWindows ? "/usr/lib" : 302Directory.SetCurrentDirectory(NativeMethodsShared.IsWindows ? 305Exec exec = PrepareExec(NativeMethodsShared.IsWindows ? "echo [%cd%]" : "echo [$PWD]"); 332if (NativeMethodsShared.GetShortFilePath(newTmp) == newTmp) 369if (NativeMethodsShared.GetShortFilePath(newTmp) == newTmp) 407if (NativeMethodsShared.GetShortFilePath(newTmp) == newTmp) 444if (NativeMethodsShared.GetShortFilePath(newTmp) == newTmp) 579if (!NativeMethodsShared.IsWindows) 640if (NativeMethodsShared.IsWindows) 663if (NativeMethodsShared.IsWindows) 694if (NativeMethodsShared.IsWindows) 726var cmdLine = NativeMethodsShared.IsWindows 742var cmdLine = NativeMethodsShared.IsWindows 792var cmdLine = NativeMethodsShared.IsWindows 888exec.Command = NativeMethodsShared.IsWindows ? "echo [%MYENVVAR%]" : "echo [$myenvvar]"; 1041Exec exec = PrepareExec(NativeMethodsShared.IsWindows ? $"type {textFilePath}" : $"cat {textFilePath}");
FindUnderPath_Tests.cs (3)
79new TaskItem(NativeMethodsShared.IsWindows ? @"C:\SomeoneElsesProject\File2.txt" : "/SomeoneElsesProject/File2.txt") }; 112Assert.Equal(NativeMethodsShared.IsWindows ? @"C:\SomeoneElsesProject\File2.txt" : "/SomeoneElsesProject/File2.txt", 134Assert.Equal(NativeMethodsShared.IsWindows ? @"C:\SomeoneElsesProject\File2.txt" : "/SomeoneElsesProject/File2.txt",
MakeDir_Tests.cs (2)
91if (NativeMethodsShared.IsWindows) 115if (!NativeMethodsShared.IsWindows)
NativeMethodsShared_Tests.cs (11)
38IntPtr kernel32Dll = NativeMethodsShared.LoadLibrary("kernel32.dll"); 41IntPtr processHandle = NativeMethodsShared.NullIntPtr; 42if (kernel32Dll != NativeMethodsShared.NullIntPtr) 44processHandle = NativeMethodsShared.GetProcAddress(kernel32Dll, "GetCurrentProcessId"); 52Assert.NotEqual(processHandle, NativeMethodsShared.NullIntPtr); 63if (kernel32Dll != NativeMethodsShared.NullIntPtr) 65NativeMethodsShared.FreeLibrary(kernel32Dll); 79DateTime nonexistentFileTime = NativeMethodsShared.GetLastWriteFileUtcTime(nonexistentFile); 92DateTime directoryTime = NativeMethodsShared.GetLastWriteFileUtcTime(directory); 106Assert.False(NativeMethodsShared.GetLastWriteDirectoryUtcTime(file, out directoryTime)); 141NativeMethodsShared.SetCurrentDirectory(nonexistentDirectory);
ResolveSDKReference_Tests.cs (2)
26private readonly string _sdkPath = NativeMethodsShared.IsWindows 1520string goodSDKLocation = NativeMethodsShared.IsWindows ? "C:\\GoodSDKLocation\\" : "/GoodSDKLocation/";
ResourceHandling\GenerateResource_Tests.cs (8)
433NativeMethodsShared.IsWindows ? bitmap.ToUpper() : bitmap, 652NativeMethodsShared.IsWindows ? bitmap.ToUpper() : bitmap); 698if (!NativeMethodsShared.IsWindows) 908if (!NativeMethodsShared.IsWindows) 2840t.StronglyTypedFileName = NativeMethodsShared.IsWindows ? "||" : "\0"; 3700System.Threading.Thread.Sleep(NativeMethodsShared.IsOSX ? 1000 : 100); 4076NativeMethodsShared.IsWindows 4166NativeMethodsShared.IsWindows ? smallestBitmapFile.ToUpperInvariant() : smallestBitmapFile,
Touch_Tests.cs (4)
26internal static string myexisting_txt = NativeMethodsShared.IsWindows ? @"c:\touch\myexisting.txt" : @"/touch/myexisting.txt"; 27internal static string mynonexisting_txt = NativeMethodsShared.IsWindows ? @"c:\touch\mynonexisting.txt" : @"/touch/mynonexisting.txt"; 28internal static string nonexisting_txt = NativeMethodsShared.IsWindows ? @"c:\touch-nonexistent\file.txt" : @"/touch-nonexistent/file.txt"; 29internal static string myreadonly_txt = NativeMethodsShared.IsWindows ? @"c:\touch\myreadonly.txt" : @"/touch/myreadonly.txt";
Unzip_Tests.cs (1)
156if (NativeMethodsShared.IsWindows)
WriteCodeFragment_Tests.cs (1)
542public static string EscapedLineSeparator => NativeMethodsShared.IsWindows ? "\\r\\n" : "\\n";
Microsoft.Build.UnitTests.Shared (14)
BootstrapLocationAttribute.cs (1)
4global using NativeMethodsShared = Microsoft.Build.Framework.NativeMethods;
DriveMapping.cs (3)
31NativeMethodsShared.ThrowExceptionForErrorCode(Marshal.GetLastWin32Error()); 44NativeMethodsShared.ThrowExceptionForErrorCode(Marshal.GetLastWin32Error()); 70NativeMethodsShared.ThrowExceptionForErrorCode(err);
DummyMappedDrive.cs (2)
25if (!NativeMethodsShared.IsWindows) 61if (_mapped && NativeMethodsShared.IsWindows)
DummyMappedDriveUtils.cs (1)
26return NativeMethods.IsWindows ? new DummyMappedDrive() : default;
LongPathSupportDisabledFactAttribute.cs (1)
35if (!NativeMethodsShared.IsMaxPathLegacyWindows())
ObjectModelHelpers.cs (2)
1987NativeMethodsShared.IsWindows 1998NativeMethodsShared.IsWindows
RequiresSymbolicLinksFactAttribute.cs (2)
22if (s_runningInAzurePipeline || !NativeMethodsShared.IsWindows) 36if (!NativeMethodsShared.MakeSymbolicLink(destinationFile, sourceFile, ref errorMessage))
RunnerUtilities.cs (1)
78if (NativeMethodsShared.IsWindows)
TestEnvironment.cs (1)
599if (NativeMethodsShared.IsUnixLike)
Microsoft.Build.Utilities.Core (131)
AssemblyFoldersEx.cs (1)
80if (!NativeMethodsShared.IsWindows)
AssemblyInfo.cs (1)
4global using NativeMethodsShared = Microsoft.Build.Framework.NativeMethods;
BuildEnvironmentHelper.cs (12)
139if (!NativeMethodsShared.IsWindows) 171if (NativeMethodsShared.IsWindows && 244if (NativeMethodsShared.IsWindows && 374NativeMethodsShared.ProcessorArchitecture == Framework.NativeMethods.ProcessorArchitectures.X64 ? "amd64" : 375NativeMethodsShared.ProcessorArchitecture == Framework.NativeMethods.ProcessorArchitectures.ARM64 ? "arm64" : string.Empty, 580MSBuildToolsDirectoryRoot = NativeMethodsShared.ProcessorArchitecture switch 582NativeMethodsShared.ProcessorArchitectures.X86 => CurrentMSBuildToolsDirectory, 583NativeMethodsShared.ProcessorArchitectures.X64 or NativeMethodsShared.ProcessorArchitectures.ARM64 585_ => throw new InternalErrorException("Unknown processor architecture " + NativeMethodsShared.ProcessorArchitecture),
FileMatcher.cs (5)
1053if (NativeMethodsShared.IsLinux && recursionState.SearchData.DirectoryPattern != null) 1194using (var matchFileExpression = new ReuseableStringBuilder(FileSpecRegexMinLength + NativeMethodsShared.MAX_PATH)) 1259bool isUncPath = NativeMethodsShared.IsWindows && fixedDir.Length > 1 2255if (NativeMethodsShared.IsWindows && 2576var maxTasks = Math.Max(1, NativeMethodsShared.GetLogicalCoreCount() / 2);
FileSystems.cs (1)
20if (NativeMethodsShared.IsWindows)
FileUtilities.cs (13)
160if (NativeMethodsShared.GetLastWriteDirectoryUtcTime(directoryPath, out lastModifiedTime)) 484if (NativeMethodsShared.IsWindows) 486string uncheckedFullPath = NativeMethodsShared.GetFullPath(path); 490string message = ResourceUtilities.FormatString(AssemblyResources.GetString("Shared.PathTooLong"), path, NativeMethodsShared.MaxPath); 509if (!NativeMethodsShared.IsWindows || !path.StartsWith(@"\\", StringComparison.Ordinal)) 564if (NativeMethodsShared.IsWindows || string.IsNullOrEmpty(value) 585if (NativeMethodsShared.IsWindows || value.IsEmpty) 670if (NativeMethodsShared.IsWindows) 764if (NativeMethodsShared.IsWindows && !EndsWithSlash(fullPath)) 1205return path.Length >= NativeMethodsShared.MaxPath; 1210bool hasMaxPath = NativeMethodsShared.HasMaxPath; 1211int maxPath = NativeMethodsShared.MaxPath; 1213return hasMaxPath && !IsRootedNoThrow(path) && NativeMethodsShared.GetCurrentDirectory().Length + path.Length + 1 /* slash */ >= maxPath;
FrameworkLocationHelper.cs (37)
90internal static string dotNetFrameworkVersionFolderPrefixV11 = NativeMethodsShared.IsWindows ? "v1.1" : "1.1"; // v1.1 is for Everett. 95internal static string dotNetFrameworkVersionFolderPrefixV20 = NativeMethodsShared.IsWindows ? "v2.0" : "2.0"; // v2.0 is for Whidbey. 99internal static string dotNetFrameworkVersionFolderPrefixV30 = NativeMethodsShared.IsWindows ? "v3.0" : "3.0"; // v3.0 is for WinFx. 113internal static string dotNetFrameworkVersionFolderPrefixV35 = NativeMethodsShared.IsWindows ? "v3.5" : "3.5"; // v3.5 is for Orcas. 119internal static string dotNetFrameworkVersionFolderPrefixV40 = NativeMethodsShared.IsWindows ? "v4.0" : "4.0"; 120internal static string dotNetFrameworkVersionFolderPrefixV45 = NativeMethodsShared.IsWindows ? "v4.5" : "4.5"; 409return NativeMethodsShared.IsUnixLike 410? Path.Combine(NativeMethodsShared.FrameworkBasePath, dotNetFrameworkVersionFolderPrefixV11) 419return NativeMethodsShared.IsUnixLike 420? Path.Combine(NativeMethodsShared.FrameworkBasePath, dotNetFrameworkVersionFolderPrefixV20) 429return NativeMethodsShared.IsUnixLike 430? Path.Combine(NativeMethodsShared.FrameworkBasePath, dotNetFrameworkVersionFolderPrefixV30) 439return NativeMethodsShared.IsUnixLike 440? Path.Combine(NativeMethodsShared.FrameworkBasePath, dotNetFrameworkVersionFolderPrefixV35) 449return NativeMethodsShared.IsUnixLike 450? Path.Combine(NativeMethodsShared.FrameworkBasePath, dotNetFrameworkVersionFolderPrefixV40) 459return NativeMethodsShared.IsUnixLike 460? Path.Combine(NativeMethodsShared.FrameworkBasePath, dotNetFrameworkVersionFolderPrefixV45) 469return NativeMethodsShared.IsUnixLike 470? Path.Combine(NativeMethodsShared.FrameworkBasePath, dotNetFrameworkVersionFolderPrefixV11) 479return NativeMethodsShared.IsUnixLike 480? Path.Combine(NativeMethodsShared.FrameworkBasePath, dotNetFrameworkVersionFolderPrefixV20) 503if (!NativeMethodsShared.IsWindows) 505s_fallbackDotNetFrameworkSdkInstallPath = NativeMethodsShared.FrameworkCurrentPath; 553if (NativeMethodsShared.IsWindows) 600if (NativeMethodsShared.IsWindows) 741if (NativeMethodsShared.IsWindows) 774if (!NativeMethodsShared.IsWindows) 782var frameworkPath = Path.Combine(NativeMethodsShared.FrameworkBasePath, prefix ?? string.Empty); 928combinedPath = NativeMethodsShared.IsWindows 930: Path.Combine(NativeMethodsShared.FrameworkBasePath, "xbuild-frameworks"); 1142dotNetFrameworkVersionFolderPrefix: NativeMethodsShared.IsWindows ? "v4.0" : "v4.5", 1373if (NativeMethodsShared.IsWindows && !CheckForFrameworkInstallation( 1395(!FileSystems.Default.FileExists(Path.Combine(generatedPathToDotNetFramework, NativeMethodsShared.IsWindows ? "MSBuild.exe" : "mcs.exe")) && 1423if (NativeMethodsShared.IsUnixLike) 1425string frameworkPath = NativeMethodsShared.FrameworkBasePath; 1514if (NativeMethodsShared.IsWindows)
ManagedFileSystem.cs (1)
26return NativeMethodsShared.IsWindows;
Modifiers.cs (1)
464if (NativeMethodsShared.IsWindows)
MSBuildNameIgnoreCaseComparer.cs (6)
25private static readonly NativeMethodsShared.ProcessorArchitectures s_runningProcessorArchitecture = NativeMethodsShared.ProcessorArchitecture; 72if ((s_runningProcessorArchitecture != NativeMethodsShared.ProcessorArchitectures.IA64) 73&& (s_runningProcessorArchitecture != NativeMethodsShared.ProcessorArchitectures.ARM)) 119if ((s_runningProcessorArchitecture != NativeMethodsShared.ProcessorArchitectures.IA64) 120&& (s_runningProcessorArchitecture != NativeMethodsShared.ProcessorArchitectures.ARM))
ProcessExtensions.cs (2)
17if (NativeMethodsShared.IsWindows) 22NativeMethodsShared.KillTree(process.Id);
ProcessorArchitecture.cs (11)
84string architecture = NativeMethodsShared.ProcessorArchitecture switch 86NativeMethodsShared.ProcessorArchitectures.X86 => X86, 87NativeMethodsShared.ProcessorArchitectures.X64 => AMD64, 88NativeMethodsShared.ProcessorArchitectures.IA64 => IA64, 89NativeMethodsShared.ProcessorArchitectures.ARM => ARM, 90NativeMethodsShared.ProcessorArchitectures.ARM64 => ARM64, 91NativeMethodsShared.ProcessorArchitectures.WASM => WASM, 92NativeMethodsShared.ProcessorArchitectures.S390X => S390X, 93NativeMethodsShared.ProcessorArchitectures.LOONGARCH64 => LOONGARCH64, 94NativeMethodsShared.ProcessorArchitectures.ARMV6 => ARMV6, 95NativeMethodsShared.ProcessorArchitectures.PPC64LE => PPC64LE,
TempFileUtilities.cs (6)
42string msbuildTempFolder = NativeMethodsShared.IsWindows ? 48if (NativeMethodsShared.IsLinux && NativeMethodsShared.mkdir(basePath, userRWX) != 0) 50if (NativeMethodsShared.chmod(basePath, userRWX) == 0) 60while (NativeMethodsShared.mkdir(pathToCheck, userRWX) != 0 && NativeMethodsShared.chmod(pathToCheck, userRWX) != 0)
ToolLocationHelper.cs (11)
1821if (NativeMethodsShared.IsWindows && platformTarget != null) 2438string registryRoot = NativeMethodsShared.IsWindows ? GetTargetPlatformMonikerRegistryRoots(registrySearchLocation) : string.Empty; 2463if (NativeMethodsShared.IsWindows && ChangeWaves.AreFeaturesEnabled(ChangeWaves.Wave17_4)) 2889if (NativeMethodsShared.IsWindows) 2911diskRoots.Add(NativeMethodsShared.FrameworkBasePath); 3386return NativeMethodsShared.ProcessorArchitectureNative switch 3388NativeMethodsShared.ProcessorArchitectures.X64 => ProcessorArchitecture.AMD64, 3389NativeMethodsShared.ProcessorArchitectures.IA64 => ProcessorArchitecture.IA64, 3390NativeMethodsShared.ProcessorArchitectures.ARM64 => ProcessorArchitecture.ARM64, 3393NativeMethodsShared.ProcessorArchitectures.X86 => null, 3394NativeMethodsShared.ProcessorArchitectures.ARM => null,
ToolTask.cs (5)
655if (NativeMethodsShared.IsWindows) 767if (NativeMethodsShared.IsWindows) 1400bool runningOnWindows = NativeMethodsShared.IsWindows; 1465batchFileForCommandLine = NativeMethodsShared.GetShortFilePath(batchFileForCommandLine); 1632if (NativeMethodsShared.IsWindows)
TrackedDependencies\CanonicalTrackedFilesHelper.cs (1)
89DateTime lastWriteTime = NativeMethodsShared.GetLastWriteFileUtcTime(item.ItemSpec);
TrackedDependencies\CanonicalTrackedInputFiles.cs (3)
478DateTime sourceTime = NativeMethodsShared.GetLastWriteFileUtcTime(sourceFullPath); 482DateTime outputFileTime = NativeMethodsShared.GetLastWriteFileUtcTime(outputFile); 526dependeeTime = NativeMethodsShared.GetLastWriteFileUtcTime(file);
TrackedDependencies\CanonicalTrackedOutputFiles.cs (2)
210DateTime fileModifiedTime = NativeMethodsShared.GetLastWriteFileUtcTime(tlogEntry); 556? NativeMethodsShared.GetLastWriteFileUtcTime(fullComputedOutput)
TrackedDependencies\DependencyTableCache.cs (2)
47DateTime lastWriteTime = NativeMethodsShared.GetLastWriteFileUtcTime(tlogFilename); 261DateTime modifiedTime = NativeMethodsShared.GetLastWriteFileUtcTime(tlogFilename);
TrackedDependencies\FileTracker.cs (2)
86private static readonly string s_tempShortPath = FileUtilities.EnsureTrailingSlash(NativeMethodsShared.GetShortFilePath(s_tempPath).ToUpperInvariant()); 89private static readonly string s_tempLongPath = FileUtilities.EnsureTrailingSlash(NativeMethodsShared.GetLongFilePath(s_tempPath).ToUpperInvariant());
TrackedDependencies\FlatTrackingData.cs (3)
409DateTime tlogLastWriteTimeUtc = NativeMethodsShared.GetLastWriteFileUtcTime(tlogFileName.ItemSpec); 513DateTime tlogLastWriteTimeUtc = NativeMethodsShared.GetLastWriteFileUtcTime(tlogFileName.ItemSpec); 665fileModifiedTimeUtc = NativeMethodsShared.GetLastWriteFileUtcTime(file);
WindowsFileSystem.cs (5)
58return NativeMethodsShared.DirectoryExistsWindows(path); 63return NativeMethodsShared.FileExistsWindows(path); 68return NativeMethodsShared.FileOrDirectoryExistsWindows(path); 73var fileLastWriteTime = NativeMethodsShared.GetLastWriteFileUtcTime(path); 81NativeMethodsShared.GetLastWriteDirectoryUtcTime(path, out var directoryLastWriteTime);
Microsoft.Build.Utilities.UnitTests (71)
AssemblyInfo.cs (1)
4global using NativeMethodsShared = Microsoft.Build.Framework.NativeMethods;
NativeMethodsShared_Tests.cs (11)
38IntPtr kernel32Dll = NativeMethodsShared.LoadLibrary("kernel32.dll"); 41IntPtr processHandle = NativeMethodsShared.NullIntPtr; 42if (kernel32Dll != NativeMethodsShared.NullIntPtr) 44processHandle = NativeMethodsShared.GetProcAddress(kernel32Dll, "GetCurrentProcessId"); 52Assert.NotEqual(processHandle, NativeMethodsShared.NullIntPtr); 63if (kernel32Dll != NativeMethodsShared.NullIntPtr) 65NativeMethodsShared.FreeLibrary(kernel32Dll); 79DateTime nonexistentFileTime = NativeMethodsShared.GetLastWriteFileUtcTime(nonexistentFile); 92DateTime directoryTime = NativeMethodsShared.GetLastWriteFileUtcTime(directory); 106Assert.False(NativeMethodsShared.GetLastWriteDirectoryUtcTime(file, out directoryTime)); 141NativeMethodsShared.SetCurrentDirectory(nonexistentDirectory);
ProcessExtensions_Tests.cs (1)
20NativeMethodsShared.IsWindows ?
ProcessorArchitecture_Tests.cs (11)
18return NativeMethodsShared.ProcessorArchitecture switch 20NativeMethodsShared.ProcessorArchitectures.X86 => ProcessorArchitecture.X86, 21NativeMethodsShared.ProcessorArchitectures.X64 => ProcessorArchitecture.AMD64, 22NativeMethodsShared.ProcessorArchitectures.IA64 => ProcessorArchitecture.IA64, 23NativeMethodsShared.ProcessorArchitectures.ARM => ProcessorArchitecture.ARM, 24NativeMethodsShared.ProcessorArchitectures.ARM64 => ProcessorArchitecture.ARM64, 25NativeMethodsShared.ProcessorArchitectures.WASM => ProcessorArchitecture.WASM, 26NativeMethodsShared.ProcessorArchitectures.S390X => ProcessorArchitecture.S390X, 27NativeMethodsShared.ProcessorArchitectures.LOONGARCH64 => ProcessorArchitecture.LOONGARCH64, 28NativeMethodsShared.ProcessorArchitectures.ARMV6 => ProcessorArchitecture.ARMV6, 29NativeMethodsShared.ProcessorArchitectures.PPC64LE => ProcessorArchitecture.PPC64LE,
TaskItem_Tests.cs (2)
227from.ItemSpec = NativeMethodsShared.IsWindows ? @"c:\subdir\Monkey.txt" : "/subdir/Monkey.txt"; 228from.GetMetadata(FileUtilities.ItemSpecModifiers.Directory).ShouldBe(NativeMethodsShared.IsWindows ? @"subdir\" : "subdir/");
ToolLocationHelper_Tests.cs (11)
376NativeMethodsShared.IsWindows ? "f:\\IDontExistAtAll" : "/IDontExistAtAll"); 388NativeMethodsShared.IsWindows ? "f:\\IDontExistAtAll" : "/IDontExistAtAll", 1264string targetFrameworkRootPath = NativeMethodsShared.IsWindows 1285string targetFrameworkRootPath = NativeMethodsShared.IsWindows 1307string targetFrameworkRootPath = NativeMethodsShared.IsWindows 1328string targetFrameworkRootPath = NativeMethodsShared.IsWindows 1351string targetFrameworkRootPath = NativeMethodsShared.IsWindows 3075string tooLongPath = NativeMethodsShared.IsWindows 3110string normalDirectory = NativeMethodsShared.IsWindows ? "c:\\SDKPath" : "/SDKPath"; 3131string frameworkPathPattern = NativeMethodsShared.IsWindows ? @"Microsoft SDKs\Windows\v8.0\ExtensionSDKs\MyFramework" : "Microsoft SDKs/Windows/v8.0/ExtensionSDKs/MyFramework"; 3132string frameworkPathPattern2 = NativeMethodsShared.IsWindows ? @"ExtensionSDKs\MyFramework" : "ExtensionSDKs/MyFramework";
ToolTask_Tests.cs (34)
40NativeMethodsShared.IsUnixLike ? "/bin" : Environment.GetFolderPath(Environment.SpecialFolder.System), 41NativeMethodsShared.IsUnixLike ? "sh" : "cmd.exe"); 111if (!NativeMethodsShared.IsWindows && string.IsNullOrEmpty(responseFileCommands) && string.IsNullOrEmpty(commandLineCommands)) 118StartInfo = GetProcessStartInfo(GenerateFullPathToTool(), NativeMethodsShared.IsWindows ? "/x" : string.Empty, null); 130t.ToolPath = NativeMethodsShared.IsWindows ? @"C:\MyAlternatePath" : "/MyAlternatePath"; 146t.ToolPath = NativeMethodsShared.IsWindows ? @"C:\MyAlternatePath" : "/MyAlternatePath"; 165string systemPath = NativeMethodsShared.IsUnixLike ? "/bin" : Environment.GetFolderPath(Environment.SpecialFolder.System); 166t.FullToolName = Path.Combine(systemPath, NativeMethodsShared.IsWindows ? "attrib.exe" : "ps"); 188t.MockCommandLineCommands = NativeMethodsShared.IsWindows ? "/C garbagegarbagegarbagegarbage.exe" : "-c garbagegarbagegarbagegarbage.exe"; 191t.ExitCode.ShouldBe(NativeMethodsShared.IsWindows ? 1 : 127); // cmd.exe error code is 1, sh error code is 127 213t.MockCommandLineCommands = NativeMethodsShared.IsWindows 240t.MockCommandLineCommands = NativeMethodsShared.IsWindows 272string singleQuote = NativeMethodsShared.IsWindows ? "'" : string.Empty; 289t.MockCommandLineCommands = NativeMethodsShared.IsWindows 313t.MockCommandLineCommands = NativeMethodsShared.IsWindows 337t.MockCommandLineCommands = NativeMethodsShared.IsWindows 361t.FullToolName = NativeMethodsShared.IsWindows ? "c:\\baz\\foo.exe" : "/baz/foo.exe"; 376string shellName = NativeMethodsShared.IsWindows ? "cmd.exe" : "sh"; 377string copyName = NativeMethodsShared.IsWindows ? "xcopy.exe" : "cp"; 383string systemPath = NativeMethodsShared.IsUnixLike ? "/bin" : Environment.GetFolderPath(Environment.SpecialFolder.System); 429string toolName = NativeMethodsShared.IsWindows ? "cmd.exe" : "sh"; 436string systemPath = NativeMethodsShared.IsUnixLike ? "/bin" : Environment.GetFolderPath(Environment.SpecialFolder.System); 457t.FullToolName = NativeMethodsShared.IsWindows ? "findstr.exe" : "grep"; 485t.FullToolName = NativeMethodsShared.IsWindows ? "findstr.exe" : "grep"; 519t.MockCommandLineCommands = NativeMethodsShared.IsWindows 546string userVarName = NativeMethodsShared.IsWindows ? "username" : "user"; 560if (NativeMethodsShared.IsWindows) 652string toolName = NativeMethodsShared.IsWindows ? "cmd" : "sh"; 693if (NativeMethodsShared.IsWindows) 732t.MockCommandLineCommands = NativeMethodsShared.IsWindows 764t.MockCommandLineCommands = NativeMethodsShared.IsWindows 861if (NativeMethodsShared.IsUnixLike // treat all UNIXy OSes as capable of UTF-8 everywhere 997_pathToShell = NativeMethodsShared.IsUnixLike ? "/bin/sh" : "cmd.exe"; 1036NativeMethodsShared.IsUnixLike ?
MSBuild (53)
AssemblyInfo.cs (1)
4global using NativeMethodsShared = Microsoft.Build.Framework.NativeMethods;
BuildEnvironmentHelper.cs (12)
139if (!NativeMethodsShared.IsWindows) 171if (NativeMethodsShared.IsWindows && 244if (NativeMethodsShared.IsWindows && 374NativeMethodsShared.ProcessorArchitecture == Framework.NativeMethods.ProcessorArchitectures.X64 ? "amd64" : 375NativeMethodsShared.ProcessorArchitecture == Framework.NativeMethods.ProcessorArchitectures.ARM64 ? "arm64" : string.Empty, 580MSBuildToolsDirectoryRoot = NativeMethodsShared.ProcessorArchitecture switch 582NativeMethodsShared.ProcessorArchitectures.X86 => CurrentMSBuildToolsDirectory, 583NativeMethodsShared.ProcessorArchitectures.X64 or NativeMethodsShared.ProcessorArchitectures.ARM64 585_ => throw new InternalErrorException("Unknown processor architecture " + NativeMethodsShared.ProcessorArchitecture),
CommunicationsUtilities.cs (1)
517if (!NativeMethodsShared.IsWindows)
FileSystems.cs (1)
20if (NativeMethodsShared.IsWindows)
FileUtilities.cs (9)
160if (NativeMethodsShared.GetLastWriteDirectoryUtcTime(directoryPath, out lastModifiedTime)) 564if (NativeMethodsShared.IsWindows || string.IsNullOrEmpty(value) 585if (NativeMethodsShared.IsWindows || value.IsEmpty) 670if (NativeMethodsShared.IsWindows) 764if (NativeMethodsShared.IsWindows && !EndsWithSlash(fullPath)) 1205return path.Length >= NativeMethodsShared.MaxPath; 1210bool hasMaxPath = NativeMethodsShared.HasMaxPath; 1211int maxPath = NativeMethodsShared.MaxPath; 1213return hasMaxPath && !IsRootedNoThrow(path) && NativeMethodsShared.GetCurrentDirectory().Length + path.Length + 1 /* slash */ >= maxPath;
ManagedFileSystem.cs (1)
26return NativeMethodsShared.IsWindows;
Modifiers.cs (1)
464if (NativeMethodsShared.IsWindows)
MSBuildClientApp.cs (1)
109NativeMethodsShared.IsWindows ? "dotnet.exe" : "dotnet");
MSBuildNameIgnoreCaseComparer.cs (6)
25private static readonly NativeMethodsShared.ProcessorArchitectures s_runningProcessorArchitecture = NativeMethodsShared.ProcessorArchitecture; 72if ((s_runningProcessorArchitecture != NativeMethodsShared.ProcessorArchitectures.IA64) 73&& (s_runningProcessorArchitecture != NativeMethodsShared.ProcessorArchitectures.ARM)) 119if ((s_runningProcessorArchitecture != NativeMethodsShared.ProcessorArchitectures.IA64) 120&& (s_runningProcessorArchitecture != NativeMethodsShared.ProcessorArchitectures.ARM))
NamedPipeUtil.cs (1)
25if (NativeMethodsShared.IsUnixLike)
OutOfProcTaskHostNode.cs (2)
825NativeMethodsShared.SetCurrentDirectory(BuildEnvironmentHelper.Instance.CurrentMSBuildToolsDirectory); 907NativeMethodsShared.SetCurrentDirectory(taskConfiguration.StartupDirectory);
TempFileUtilities.cs (6)
42string msbuildTempFolder = NativeMethodsShared.IsWindows ? 48if (NativeMethodsShared.IsLinux && NativeMethodsShared.mkdir(basePath, userRWX) != 0) 50if (NativeMethodsShared.chmod(basePath, userRWX) == 0) 60while (NativeMethodsShared.mkdir(pathToCheck, userRWX) != 0 && NativeMethodsShared.chmod(pathToCheck, userRWX) != 0)
WindowsFileSystem.cs (5)
58return NativeMethodsShared.DirectoryExistsWindows(path); 63return NativeMethodsShared.FileExistsWindows(path); 68return NativeMethodsShared.FileOrDirectoryExistsWindows(path); 73var fileLastWriteTime = NativeMethodsShared.GetLastWriteFileUtcTime(path); 81NativeMethodsShared.GetLastWriteDirectoryUtcTime(path, out var directoryLastWriteTime);
XMake.cs (6)
1054NativeMethodsShared.RestoreConsoleMode(s_originalConsoleMode); 1846if (NativeMethodsShared.IsWindows && 2053int numberOfCpus = NativeMethodsShared.GetLogicalCoreCount(); 2797(var acceptAnsiColorCodes, var outputIsScreen, s_originalConsoleMode) = NativeMethodsShared.QueryIsScreenAndTryEnableAnsiColorCodes(); 2950(_, _, s_originalConsoleMode) = NativeMethodsShared.QueryIsScreenAndTryEnableAnsiColorCodes(); 4531Console.WriteLine(ResourceUtilities.FormatResourceStringStripCodeAndKeyword("MSBuildVersionMessage", ProjectCollection.DisplayVersion, NativeMethods.FrameworkName));