863 references to NativeMethods
Microsoft.Build (163)
AssemblyInfo.cs (1)
4global using NativeMethodsShared = Microsoft.Build.Framework.NativeMethods;
BackEnd\BuildManager\BuildManager.cs (5)
460if (NativeMethodsShared.IsWindows || parameters.LowPriority) 1052_buildTelemetry.FrameworkName = NativeMethodsShared.FrameworkName; 1070var sacState = NativeMethodsShared.GetSACState(); 1072_buildTelemetry.SACEnabled = sacState == NativeMethodsShared.SAC_State.Evaluation || sacState == NativeMethodsShared.SAC_State.Enforcement;
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)
843if (!NativeMethodsShared.IsWindows || BuildEnvironmentHelper.Instance.RunningInVisualStudio) 859NativeMethodsShared.MemoryStatus memoryStatus = NativeMethodsShared.GetMemoryStatus(); 894memoryStatus = 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)
905entryToComplete.RequestConfiguration.SavedCurrentDirectory = NativeMethodsShared.GetCurrentDirectory(); 1097NativeMethodsShared.SetCurrentDirectory(_requestEntry.ProjectRootDirectory); 1267_requestEntry.RequestConfiguration.SavedCurrentDirectory = NativeMethodsShared.GetCurrentDirectory(); 1326NativeMethodsShared.SetCurrentDirectory(_requestEntry.RequestConfiguration.SavedCurrentDirectory);
BackEnd\Components\RequestBuilder\TargetUpToDateChecker.cs (5)
988oldestOutputFileTime = NativeMethodsShared.GetLastWriteFileUtcTime(oldestOutputFullPath); 1013candidateOutputFileTime = NativeMethodsShared.GetLastWriteFileUtcTime(candidateOutputFullPath); 1048inputFileTime = NativeMethodsShared.GetLastWriteFileUtcTime(unescapedInputFullPath); 1203var path1WriteTime = NativeMethodsShared.GetLastWriteFileUtcTime(path1); 1206var path2WriteTime = NativeMethodsShared.GetLastWriteFileUtcTime(path2);
BackEnd\Components\RequestBuilder\TaskBuilder.cs (1)
417NativeMethodsShared.SetCurrentDirectory(_buildRequestEntry.ProjectRootDirectory);
BackEnd\Components\Scheduler\Scheduler.cs (1)
213_coreLimit = NativeMethodsShared.GetLogicalCoreCount();
BackEnd\Components\SdkResolution\SdkResolverService.cs (1)
537NativeMethodsShared.GetLogicalCoreCount(),
BackEnd\Node\InProcNode.cs (3)
143_savedCurrentDirectory = NativeMethodsShared.GetCurrentDirectory(); 336NativeMethodsShared.SetCurrentDirectory(_savedCurrentDirectory); 468_savedCurrentDirectory = NativeMethodsShared.GetCurrentDirectory();
BackEnd\Node\OutOfProcNode.cs (4)
476NativeMethodsShared.SetCurrentDirectory(BuildEnvironmentHelper.Instance.CurrentMSBuildToolsDirectory); 705NativeMethodsShared.SetCurrentDirectory(BuildParameters.StartupDirectory); 710NativeMethodsShared.SetCurrentDirectory(BuildEnvironmentHelper.Instance.CurrentMSBuildToolsDirectory); 861if (!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; 499var importSearchPathsTable = GetProjectImportSearchPathsTable(toolsVersion.Name, NativeMethodsShared.GetOSNameForExtensionsPath());
Evaluation\Evaluator.cs (3)
1146if (!NativeMethodsShared.IsWindows) 1148SetBuiltInProperty(ReservedPropertyNames.osName, NativeMethodsShared.OSName); 1149SetBuiltInProperty(ReservedPropertyNames.frameworkToolsRoot, NativeMethodsShared.FrameworkBasePath);
Evaluation\Expander.cs (3)
1658if (!NativeMethodsShared.IsWindows) 1698if (!NativeMethodsShared.IsWindows && !registryKeyName.StartsWith("HKEY_CURRENT_USER", StringComparison.OrdinalIgnoreCase)) 1708return NativeMethodsShared.FrameworkBasePath + Path.DirectorySeparatorChar;
Evaluation\IntrinsicFunctions.cs (8)
195if (!NativeMethodsShared.IsWindows) 211if (!NativeMethodsShared.IsWindows) 224if (!NativeMethodsShared.IsWindows) 246if (!NativeMethodsShared.IsWindows) 277if (!NativeMethodsShared.IsWindows && !keyName.StartsWith("HKEY_CURRENT_USER", StringComparison.OrdinalIgnoreCase)) 286return Path.Combine(NativeMethodsShared.FrameworkBasePath, m.Groups[0].Value) + Path.DirectorySeparatorChar; 551return NativeMethodsShared.IsUnixLike; 560return 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)) 1212return path.Length >= NativeMethodsShared.MaxPath; 1217bool hasMaxPath = NativeMethodsShared.HasMaxPath; 1218int maxPath = NativeMethodsShared.MaxPath; 1220return 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 (4)
58return NativeMethodsShared.DirectoryExistsWindows(path); 72return NativeMethodsShared.FileOrDirectoryExistsWindows(path); 77var fileLastWriteTime = NativeMethodsShared.GetLastWriteFileUtcTime(path); 85NativeMethodsShared.GetLastWriteDirectoryUtcTime(path, out var directoryLastWriteTime);
Microsoft.Build.BuildCheck.UnitTests (8)
AssemblyInfo.cs (1)
4global using NativeMethodsShared = Microsoft.Build.Framework.NativeMethods;
DoubleWritesAnalyzer_Tests.cs (1)
31string projectFile = NativeMethodsShared.IsWindows ? @"C:\fake\project.proj" : "/fake/project.proj";
SharedOutputPathCheck_Tests.cs (6)
41string projectFile1 = NativeMethodsShared.IsWindows ? "C:\\fake1\\project1.proj" : "/fake1/project1.proj"; 51string projectFile2 = NativeMethodsShared.IsWindows ? "C:\\fake2\\project2.proj" : "/fake2/project2.proj"; 68string projectFile1 = NativeMethodsShared.IsWindows ? "C:\\fake\\project1.proj" : "/fake/project1.proj"; 69string projectFile2 = NativeMethodsShared.IsWindows ? "C:\\fake\\project2.proj" : "/fake/project2.proj"; 93string wrongPathSeparator = NativeMethodsShared.IsWindows ? "/" : "\\"; 108string projectFolder = NativeMethodsShared.IsWindows ? "C:\\fake\\" : "/fake/";
Microsoft.Build.CommandLine.UnitTests (16)
AssemblyInfo.cs (1)
4global using NativeMethodsShared = Microsoft.Build.Framework.NativeMethods;
TerminalLogger_Tests.cs (3)
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"; 41private readonly string _projectFileWithNonAnsiSymbols = NativeMethods.IsUnixLike ? "/src/проектТерминал/㐇𠁠𪨰𫠊𫦠𮚮⿕.proj" : @"C:\src\проектТерминал\㐇𠁠𪨰𫠊𫦠𮚮⿕.proj";
XMake_Tests.cs (12)
109parameters[1].ShouldBe(Convert.ToString(NativeMethodsShared.GetLogicalCoreCount())); 1156NativeMethodsShared.IsWindows ? @"c:\bin\msbuild.exe" : "/msbuild.exe", 1183private readonly string _pathToArbitraryBogusFile = NativeMethodsShared.IsWindows // OK on 64 bit as well 1193var msbuildParameters = "\"" + _pathToArbitraryBogusFile + "\"" + (NativeMethodsShared.IsWindows ? " /v:diag" : " -v:diag"); 1199output.ShouldContain(RunnerUtilities.PathToCurrentlyRunningMsBuildExe + (NativeMethodsShared.IsWindows ? " /v:diag " : " -v:diag ") + _pathToArbitraryBogusFile, Case.Insensitive); 1208var msbuildParameters = "\"" + _pathToArbitraryBogusFile + "\"" + (NativeMethodsShared.IsWindows ? " /v:diag" : " -v:diag"); 1214if (NativeMethodsShared.IsWindows) 1222output.ShouldContain(RunnerUtilities.PathToCurrentlyRunningMsBuildExe + (NativeMethodsShared.IsWindows ? " /v:diag " : " -v:diag ") + _pathToArbitraryBogusFile, Case.Insensitive); 1238var msbuildParameters = "\"" + _pathToArbitraryBogusFile + "\"" + (NativeMethodsShared.IsWindows ? " /v:diag" : " -v:diag"); 1248output.ShouldContain(RunnerUtilities.PathToCurrentlyRunningMsBuildExe + (NativeMethodsShared.IsWindows ? " /v:diag " : " -v:diag ") + _pathToArbitraryBogusFile, Case.Insensitive); 2171fileLoggerParameters = new[] { "Parameter1", "verbosity=Normal;logfile=" + (NativeMethodsShared.IsWindows ? "c:\\temp\\cat.log" : "/tmp/cat.log") }; 2662ProjectCollection.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)
1775Assert.Equal(NativeMethodsShared.GetCurrentDirectory(), rootElement.DirectoryPath);
Construction\SolutionFile_Tests.cs (1)
709return !NativeMethodsShared.IsWindows ? path.Replace('\\', '/') : path;
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 ? 1524xml.AddImport(NativeMethodsShared.IsWindows ? 2254NativeMethodsShared.IsWindows ? @"c:\" + Guid.NewGuid().ToString() + @"\**\i1" : "/" + Guid.NewGuid().ToString() + "/**/i1"); 2444NativeMethodsShared.IsWindows ? @"c:\subdir1\**\subdir2\**\*.x?x" : "/subdir1/**/subdir2/**/*.x?x"); 2448NativeMethodsShared.IsWindows ? @"c:\subdir1\a\b\subdir2\c\i1.xyx" : "/subdir1/a/b/subdir2/c/i1.xyx")[0].Xml; 2451NativeMethodsShared.IsWindows ?
Definition\Project_Tests.cs (3)
44private readonly int RootPrefixLength = NativeMethodsShared.IsWindows ? 3 : 1; 683if (NativeMethodsShared.IsWindows) 2835var itemElements = NativeMethodsShared.GetLogicalCoreCount() * 5;
Definition\ProjectCollection_Tests.cs (1)
409string projectDirectory = NativeMethodsShared.IsWindows ? "c:\\1" : "/l";
Definition\ProjectItem_Tests.cs (12)
286NativeMethodsShared.IsWindows ? @"<i Include='c:\foo\bar.baz'/>" : @"<i Include='/foo/bar.baz'/>"); 300NativeMethodsShared.IsWindows ? @"c:\foo\bar.baz" : "/foo/bar.baz", 302Assert.Equal(NativeMethodsShared.IsWindows ? @"c:\" : "/", item.GetMetadataValue("RootDir")); 305Assert.Equal(NativeMethodsShared.IsWindows ? @"c:\foo\" : "/foo/", item.GetMetadataValue("RelativeDir")); 306Assert.Equal(NativeMethodsShared.IsWindows ? @"foo\" : "foo/", item.GetMetadataValue("Directory")); 309NativeMethodsShared.IsWindows ? @"c:\foo\bar.baz" : "/foo/bar.baz", 371"<i Include='" + directory + (NativeMethodsShared.IsWindows ? @"\**\*'/>" : "/**/*'/>")); 373Assert.Equal(NativeMethodsShared.IsWindows ? @"b\" : "b/", item.GetMetadataValue("RecursiveDir")); 416IList<ProjectItem> items = ObjectModelHelpers.GetItemsFromFragment("<i Include='i0;" + directory + (NativeMethodsShared.IsWindows ? @"\**\*;i2'/>" : "/**/*;i2'/>")); 420Assert.Equal(NativeMethodsShared.IsWindows ? @"b\" : "b/", items[1].GetMetadataValue("RecursiveDir")); 753if (NativeMethodsShared.IsWindows) 1652<i Include='i1.cpp;" + (NativeMethodsShared.IsWindows ? @"c:\bar\i2.cpp" : "/bar/i2.cpp") + @"'>
Definition\ProjectItemDefinition_Tests.cs (4)
241<i Include='" + (NativeMethodsShared.IsWindows ? @"c:\a\b.ext" : "/a/b.ext") + @"'/> 268<i Include='" + (NativeMethodsShared.IsWindows ? @"c:\a\b.ext" : "/a/b.ext") + @"'/> 295<i Include='" + (NativeMethodsShared.IsWindows ? @"c:\a\b.ext" : "/a/b.ext") + @"'/> 324<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)) 1212return path.Length >= NativeMethodsShared.MaxPath; 1217bool hasMaxPath = NativeMethodsShared.HasMaxPath; 1218int maxPath = NativeMethodsShared.MaxPath; 1220return 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 (4)
58return NativeMethodsShared.DirectoryExistsWindows(path); 72return NativeMethodsShared.FileOrDirectoryExistsWindows(path); 77var fileLastWriteTime = NativeMethodsShared.GetLastWriteFileUtcTime(path); 85NativeMethodsShared.GetLastWriteDirectoryUtcTime(path, out var directoryLastWriteTime);
Microsoft.Build.Engine.UnitTests (152)
AssemblyInfo.cs (1)
4global using NativeMethodsShared = Microsoft.Build.Framework.NativeMethods;
BackEnd\BuildManager_Tests.cs (1)
4038MaxNodeCount = NativeMethodsShared.GetLogicalCoreCount(),
BackEnd\BuildRequestConfiguration_Tests.cs (1)
541if (!NativeMethodsShared.IsWindows)
BackEnd\TargetUpToDateChecker_Tests.cs (6)
1043NativeMethodsShared.CreateFile( 1044inputSymlink, NativeMethodsShared.GENERIC_READ | 0x100 /* FILE_WRITE_ATTRIBUTES */, 1045NativeMethodsShared.FILE_SHARE_READ, IntPtr.Zero, NativeMethodsShared.OPEN_EXISTING, 1046NativeMethodsShared.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_NewParser_Tests.cs (1)
160return !NativeMethodsShared.IsWindows ? path.Replace('\\', '/') : path;
Construction\SolutionFile_OldParser_Tests.cs (5)
36p.FullPath = NativeMethodsShared.IsWindows ? "c:\\foo.sln" : "/foo.sln"; 77p.FullPath = NativeMethodsShared.IsWindows ? "c:\\foo.sln" : "/foo.sln"; 96p.FullPath = NativeMethodsShared.IsWindows ? "c:\\foo.sln" : "/foo.sln"; 152p.FullPath = NativeMethodsShared.IsWindows ? "c:\\foo.sln" : "/foo.sln"; 715p.FullPath = NativeMethodsShared.IsWindows ? "c:\\foo.sln" : "/foo.sln";
Definition\Toolset_Tests.cs (2)
56if (NativeMethodsShared.IsWindows) 221if (NativeMethodsShared.IsUnixLike)
Definition\ToolsetConfigurationReader_Tests.cs (2)
567if (NativeMethodsShared.IsWindows) 572else if (NativeMethodsShared.IsOSX)
Definition\ToolsVersion_Tests.cs (18)
35string dir = NativeMethodsShared.IsWindows ? "c:\\directory1\\directory2" : "/directory1/directory2"; 36string overrideDir = NativeMethodsShared.IsWindows ? "c:\\msbuildoverridetasks" : "/msbuildoverridetasks"; 161NativeMethodsShared.IsWindows ? "c:\\directory1\\directory2" : "/directory1/directory2", 242string dir = NativeMethodsShared.IsWindows ? "c:\\directory1\\directory2" : "/directory1/directory2"; 243string overrideDir = NativeMethodsShared.IsWindows ? "c:\\msbuildoverridetasks" : "/msbuildoverridetasks"; 928NativeMethodsShared.IsWindows ? "c:\\inline" : "/inline", 995new DefaultTasksFile(NativeMethodsShared.IsWindows 1004new DefaultTasksFile(NativeMethodsShared.IsWindows 1010new DefaultTasksFile(NativeMethodsShared.IsWindows 1016new DefaultTasksFile(NativeMethodsShared.IsWindows 1022new DefaultTasksFile(NativeMethodsShared.IsWindows 1028new DefaultTasksFile(NativeMethodsShared.IsWindows 1034new DefaultTasksFile(NativeMethodsShared.IsWindows 1042new DefaultTasksFile(NativeMethodsShared.IsWindows 1050new DefaultTasksFile(NativeMethodsShared.IsWindows 1056new DefaultTasksFile(NativeMethodsShared.IsWindows 1069new DefaultTasksFile(NativeMethodsShared.IsWindows 1078new DefaultTasksFile(NativeMethodsShared.IsWindows
Evaluation\Evaluator_Tests.cs (13)
139string fooPath = NativeMethodsShared.IsWindows ? @"c:\temp\foo.import" : "/temp/foo.import"; 140string barPath = NativeMethodsShared.IsWindows ? @"c:\temp\bar.import" : "/temp/bar.import"; 1328string targets1FileName = NativeMethodsShared.IsWindows ? @"c:\a\t1.targets" : "/a/t1.targets"; 1329string aDirName = NativeMethodsShared.IsWindows ? @"c:\a\" : "/a/"; 1330string targets2FileName = NativeMethodsShared.IsWindows ? @"c:\a\b\t2.targets" : "/a/b/t2.targets"; 1331string bDirName = NativeMethodsShared.IsWindows ? @"c:\a\b\" : "/a/b/"; 1332string targets3FileName = NativeMethodsShared.IsWindows ? @"c:\t3.targets" : "/t3.targets"; 1333string rootDirName = NativeMethodsShared.IsWindows ? @"c:\" : "/"; 1334string aProjName = NativeMethodsShared.IsWindows ? @"c:\a\p.proj" : "/a/p.proj"; 2764string file = NativeMethodsShared.IsWindows ? @"c:\foo\bar.csproj" : "/foo/bar.csproj"; 2783string file = NativeMethodsShared.IsWindows ? @"c:\bar.csproj" : "/bar.csproj"; 2784string dir = NativeMethodsShared.IsWindows ? @"c:\" : "/"; 3824if (NativeMethodsShared.IsUnixLike)
Evaluation\Expander_Tests.cs (10)
41private static readonly string s_rootPathPrefix = NativeMethodsShared.IsWindows ? "C:\\" : Path.VolumeSeparatorChar.ToString(); 1370NativeMethodsShared.IsWindows ? @"subdir1\engine.dll" : "subdir1/engine.dll", project.FullPath); 1374NativeMethodsShared.IsWindows ? @"subdir2\tasks.dll" : "subdir2/tasks.dll", project.FullPath); 1860string envVar = NativeMethodsShared.IsWindows ? "TEMP" : "USER"; 3813string envVar = NativeMethodsShared.IsWindows ? "TEMP" : "USER"; 3837string envVar = NativeMethodsShared.IsWindows ? "TEMP" : "USER"; 3861string envVar = NativeMethodsShared.IsWindows ? "TEMP" : "USER"; 3885string envVar = NativeMethodsShared.IsWindows ? "TEMP" : "USER"; 4284if (NativeMethodsShared.IsWindows) 4289if (!NativeMethodsShared.IsWindows)
Evaluation\ImportFromMSBuildExtensionsPath_Tests.cs (7)
472<searchPaths os=""" + NativeMethodsShared.GetOSNameForExtensionsPath() + @"""> 554<searchPaths os=""" + NativeMethodsShared.GetOSNameForExtensionsPath() + @"""> 615<searchPaths os=""" + NativeMethodsShared.GetOSNameForExtensionsPath() + @"""> 685<searchPaths os=""" + NativeMethodsShared.GetOSNameForExtensionsPath() + @"""> 751<searchPaths os=""" + NativeMethodsShared.GetOSNameForExtensionsPath() + @"""> 818<searchPaths os=""" + NativeMethodsShared.GetOSNameForExtensionsPath() + @"""> 963<searchPaths os=""" + NativeMethodsShared.GetOSNameForExtensionsPath() + @""">
Evaluation\ItemEvaluation_Tests.cs (1)
606if (!NativeMethodsShared.IsWindows)
Evaluation\ItemSpec_Tests.cs (1)
44var 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(); 1396MaxNodeCount = NativeMethodsShared.GetLogicalCoreCount(), 1452var referenceNumbers = Enumerable.Range(2, NativeMethodsShared.GetLogicalCoreCount() * 2).ToArray(); 1469MaxNodeCount = NativeMethodsShared.GetLogicalCoreCount(), 1515var referenceNumbers = Enumerable.Range(2, NativeMethodsShared.GetLogicalCoreCount() * 2).ToArray(); 1529MaxNodeCount = NativeMethodsShared.GetLogicalCoreCount(), 1579var projectPaths = Enumerable.Range(0, NativeMethodsShared.GetLogicalCoreCount()) 1609MaxNodeCount = NativeMethodsShared.GetLogicalCoreCount()
Utilities_Tests.cs (1)
95'"' + (NativeMethodsShared.IsUnixLike ? "-pp:" : "/pp:") + outputFile.Path + '"'}));
Microsoft.Build.Framework (5)
EncodingUtilities.cs (3)
58if (NativeMethods.IsWindows) 64s_currentOemEncoding = Encoding.GetEncoding(NativeMethods.GetOEMCP()); 224if (!NativeMethods.IsWindows)
NativeMethods.cs (2)
1195bool success = NativeMethods.GetFileAttributesEx(path, 0, ref data); 1197if (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 (95)
AssemblyDependency\AssemblyInformation.cs (1)
246if (!NativeMethodsShared.IsWindows)
AssemblyDependency\AssemblyMetadata.cs (1)
30ScatterFiles = NativeMethodsShared.IsWindows ? import.Files : null;
AssemblyDependency\Reference.cs (1)
514else if (NativeMethodsShared.IsWindows)
AssemblyDependency\ResolveAssemblyReference.cs (1)
3220p => NativeMethodsShared.GetLastWriteFileUtcTime(p),
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),
Copy.cs (3)
46private static readonly int DefaultCopyParallelism = NativeMethodsShared.GetLogicalCoreCount() > 4 ? 6 : 4; 322TryCopyViaLink(SymbolicLinkComment, MessageImportance.Normal, sourceFileState, destinationFileState, out symbolicLinkCreated, ref errorMessage, (source, destination, errMessage) => NativeMethodsShared.MakeSymbolicLink(destination, source, ref errorMessage)); 325if (!NativeMethodsShared.IsWindows)
Exec.cs (7)
74if (NativeMethodsShared.IsUnixLike) 213if (!NativeMethodsShared.IsUnixLike) 258if (!NativeMethodsShared.IsUnixLike) 496if (NativeMethodsShared.IsWindows) 573if (NativeMethodsShared.IsUnixLike) 588if (NativeMethodsShared.IsWindows) 649protected 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 (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)) 1212return path.Length >= NativeMethodsShared.MaxPath; 1217bool hasMaxPath = NativeMethodsShared.HasMaxPath; 1218int maxPath = NativeMethodsShared.MaxPath; 1220return 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 (1)
275if (!NativeMethodsShared.IsWindows)
GenerateResource.cs (7)
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); 2832if (!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)
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 (4)
58return NativeMethodsShared.DirectoryExistsWindows(path); 72return NativeMethodsShared.FileOrDirectoryExistsWindows(path); 77var fileLastWriteTime = NativeMethodsShared.GetLastWriteFileUtcTime(path); 85NativeMethodsShared.GetLastWriteDirectoryUtcTime(path, out var directoryLastWriteTime);
Microsoft.Build.Tasks.UnitTests (92)
AddToWin32Manifest_Tests.cs (1)
187NativeMethodsShared.FreeLibrary(hModule);
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)
157if (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)
1999NativeMethodsShared.IsWindows 2010NativeMethodsShared.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)
604if (NativeMethodsShared.IsUnixLike)
Microsoft.Build.Utilities.Core (110)
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 (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)) 1212return path.Length >= NativeMethodsShared.MaxPath; 1217bool hasMaxPath = NativeMethodsShared.HasMaxPath; 1218int maxPath = NativeMethodsShared.MaxPath; 1220return 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)
LockCheck.cs (1)
260if (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))
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) 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)
WindowsFileSystem.cs (4)
58return NativeMethodsShared.DirectoryExistsWindows(path); 72return NativeMethodsShared.FileOrDirectoryExistsWindows(path); 77var fileLastWriteTime = NativeMethodsShared.GetLastWriteFileUtcTime(path); 85NativeMethodsShared.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 765t.MockCommandLineCommands = NativeMethodsShared.IsWindows 862if (NativeMethodsShared.IsUnixLike // treat all UNIXy OSes as capable of UTF-8 everywhere 998_pathToShell = NativeMethodsShared.IsUnixLike ? "/bin/sh" : "cmd.exe"; 1037NativeMethodsShared.IsUnixLike ?
MSBuild (61)
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)) 1212return path.Length >= NativeMethodsShared.MaxPath; 1217bool hasMaxPath = NativeMethodsShared.HasMaxPath; 1218int maxPath = NativeMethodsShared.MaxPath; 1220return 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)
TerminalLogger\TerminalLogger.cs (2)
273(_, _, _originalConsoleMode) = NativeMethodsShared.QueryIsScreenAndTryEnableAnsiColorCodes(); 374NativeMethodsShared.RestoreConsoleMode(_originalConsoleMode);
WindowsFileSystem.cs (4)
58return NativeMethodsShared.DirectoryExistsWindows(path); 72return NativeMethodsShared.FileOrDirectoryExistsWindows(path); 77var fileLastWriteTime = NativeMethodsShared.GetLastWriteFileUtcTime(path); 85NativeMethodsShared.GetLastWriteDirectoryUtcTime(path, out var directoryLastWriteTime);
XMake.cs (13)
1065NativeMethodsShared.RestoreConsoleMode(s_originalConsoleMode); 1763NativeMethodsShared.LongPathsStatus longPaths = NativeMethodsShared.IsLongPathsEnabled(); 1764if (longPaths != NativeMethodsShared.LongPathsStatus.NotApplicable) 1775NativeMethodsShared.SAC_State SAC_State = NativeMethodsShared.GetSACState(); 1776if (SAC_State != NativeMethodsShared.SAC_State.NotApplicable && SAC_State != NativeMethodsShared.SAC_State.Missing) 1881if (NativeMethodsShared.IsWindows && 2088int numberOfCpus = NativeMethodsShared.GetLogicalCoreCount(); 2837(var acceptAnsiColorCodes, var outputIsScreen, s_originalConsoleMode) = NativeMethodsShared.QueryIsScreenAndTryEnableAnsiColorCodes(); 2990(_, _, s_originalConsoleMode) = NativeMethodsShared.QueryIsScreenAndTryEnableAnsiColorCodes(); 4577Console.WriteLine(ResourceUtilities.FormatResourceStringStripCodeAndKeyword("MSBuildVersionMessage", ProjectCollection.DisplayVersion, NativeMethods.FrameworkName));