771 references to NativeMethods
Microsoft.Build (88)
AssemblyInfo.cs (1)
4
global using NativeMethodsShared = Microsoft.Build.Framework.
NativeMethods
;
BackEnd\BuildManager\BuildManager.cs (9)
506
if (
NativeMethodsShared
.IsWindows || parameters.LowPriority)
795
ErrorUtilities.VerifyThrowInvalidOperation(
NativeMethodsShared
.ProcessorArchitecture ==
NativeMethodsShared
.ProcessorArchitectures.X64, "ReportFileAccessesX64Only");
1145
_buildTelemetry.BuildEngineFrameworkName =
NativeMethodsShared
.FrameworkName;
1159
var sacState =
NativeMethodsShared
.GetSACState();
1161
_buildTelemetry.SACEnabled = sacState ==
NativeMethodsShared
.SAC_State.Evaluation || sacState ==
NativeMethodsShared
.SAC_State.Enforcement;
1251
NativeMethodsShared
.FrameworkName,
1273
BuildEngineFrameworkName =
NativeMethodsShared
.FrameworkName,
BackEnd\BuildManager\BuildParameters.cs (1)
65
private static string s_startupDirectory =
NativeMethodsShared
.GetCurrentDirectory();
BackEnd\Client\MSBuildClient.cs (2)
217
NativeMethodsShared
.RestoreConsoleMode(_originalConsoleMode);
361
(var acceptAnsiColorCodes, var outputIsScreen, _originalConsoleMode) =
NativeMethodsShared
.QueryIsScreenAndTryEnableAnsiColorCodes();
BackEnd\Components\BuildRequestEngine\BuildRequestEngine.cs (4)
888
if (!
NativeMethodsShared
.IsWindows || BuildEnvironmentHelper.Instance.RunningInVisualStudio)
904
NativeMethodsShared
.MemoryStatus memoryStatus =
NativeMethodsShared
.GetMemoryStatus();
939
memoryStatus =
NativeMethodsShared
.GetMemoryStatus();
BackEnd\Components\Caching\ResultsCache.cs (1)
252
capacity => new ConcurrentDictionary<int, BuildResult>(
NativeMethodsShared
.GetLogicalCoreCount(), capacity));
BackEnd\Components\Communications\DetouredNodeLauncher.cs (1)
114
new BreakawayChildProcess(
NativeMethodsShared
.IsWindows ? "VBCSCompiler.exe" : "VBCSCompiler")
BackEnd\Components\Communications\NodeLauncher.cs (3)
65
return
NativeMethodsShared
.IsWindows
232
NativeMethodsShared
.CloseHandle(processInfo.hProcess);
237
NativeMethodsShared
.CloseHandle(processInfo.hThread);
BackEnd\Components\Communications\NodeProviderOutOfProcBase.cs (2)
641
return Math.Max(1, (3 *
NativeMethodsShared
.GetLogicalCoreCount()) / 2);
815
if (
NativeMethodsShared
.IsWindows)
BackEnd\Components\Communications\RarNodeLauncher.cs (1)
56
if (
NativeMethodsShared
.IsWindows)
BackEnd\Components\RequestBuilder\TargetUpToDateChecker.cs (5)
988
oldestOutputFileTime =
NativeMethodsShared
.GetLastWriteFileUtcTime(oldestOutputFullPath);
1013
candidateOutputFileTime =
NativeMethodsShared
.GetLastWriteFileUtcTime(candidateOutputFullPath);
1048
inputFileTime =
NativeMethodsShared
.GetLastWriteFileUtcTime(unescapedInputFullPath);
1203
var path1WriteTime =
NativeMethodsShared
.GetLastWriteFileUtcTime(path1);
1206
var path2WriteTime =
NativeMethodsShared
.GetLastWriteFileUtcTime(path2);
BackEnd\Components\Scheduler\Scheduler.cs (1)
243
_coreLimit =
NativeMethodsShared
.GetLogicalCoreCount();
BackEnd\Components\SdkResolution\SdkResolverService.cs (1)
547
NativeMethodsShared
.GetLogicalCoreCount(),
BackEnd\Node\InProcNode.cs (3)
148
_savedCurrentDirectory =
NativeMethodsShared
.GetCurrentDirectory();
351
NativeMethodsShared
.SetCurrentDirectory(_savedCurrentDirectory);
487
_savedCurrentDirectory =
NativeMethodsShared
.GetCurrentDirectory();
BackEnd\Node\OutOfProcNode.cs (4)
495
NativeMethodsShared
.SetCurrentDirectory(BuildEnvironmentHelper.Instance.CurrentMSBuildToolsDirectory);
722
NativeMethodsShared
.SetCurrentDirectory(BuildParameters.StartupDirectory);
727
NativeMethodsShared
.SetCurrentDirectory(BuildEnvironmentHelper.Instance.CurrentMSBuildToolsDirectory);
884
if (!lowPriority ||
NativeMethodsShared
.IsWindows)
BackEnd\Node\OutOfProcServerNode.cs (3)
255
NativeMethodsShared
.SetCurrentDirectory(BuildEnvironmentHelper.Instance.CurrentMSBuildToolsDirectory);
409
if (
NativeMethodsShared
.IsWindows && command.ConsoleConfiguration.BufferWidth > 0)
444
NativeMethodsShared
.SetCurrentDirectory(BuildEnvironmentHelper.Instance.CurrentMSBuildToolsDirectory);
BackEnd\Shared\BuildRequestConfiguration.cs (2)
455
NativeMethodsShared
.SetCurrentDirectory(BuildParameters.StartupDirectory);
460
NativeMethodsShared
.SetCurrentDirectory(
CommunicationsUtilities.cs (1)
287
if (includeSessionId &&
NativeMethodsShared
.IsWindows)
Construction\ProjectRootElement.cs (3)
179
_directory =
NativeMethodsShared
.GetCurrentDirectory();
204
_directory =
NativeMethodsShared
.GetCurrentDirectory();
261
_directory =
NativeMethodsShared
.GetCurrentDirectory();
Definition\ToolsetReader.cs (3)
149
if (
NativeMethodsShared
.IsWindows || registryReader != null)
167
var libraryPath =
NativeMethodsShared
.FrameworkBasePath;
493
var importSearchPathsTable = GetProjectImportSearchPathsTable(toolsVersion.Name,
NativeMethodsShared
.GetOSNameForExtensionsPath());
Evaluation\Evaluator.cs (3)
1159
if (!
NativeMethodsShared
.IsWindows)
1161
SetBuiltInProperty(ReservedPropertyNames.osName,
NativeMethodsShared
.OSName);
1162
SetBuiltInProperty(ReservedPropertyNames.frameworkToolsRoot,
NativeMethodsShared
.FrameworkBasePath);
Evaluation\Expander.cs (2)
1786
if (!
NativeMethodsShared
.IsWindows && !registryKeyName.StartsWith("HKEY_CURRENT_USER", StringComparison.OrdinalIgnoreCase))
1796
return
NativeMethodsShared
.FrameworkBasePath + Path.DirectorySeparatorChar;
Evaluation\IntrinsicFunctions.cs (4)
288
if (!
NativeMethodsShared
.IsWindows && !keyName.StartsWith("HKEY_CURRENT_USER", StringComparison.OrdinalIgnoreCase))
297
return Path.Combine(
NativeMethodsShared
.FrameworkBasePath, m.Groups[0].Value) + Path.DirectorySeparatorChar;
588
return
NativeMethodsShared
.IsUnixLike;
597
return
NativeMethodsShared
.IsBSD;
Graph\ProjectGraph.cs (2)
341
NativeMethodsShared
.GetLogicalCoreCount(),
382
NativeMethodsShared
.GetLogicalCoreCount(),
Instance\HostServices.cs (1)
89
if (
NativeMethodsShared
.IsWindows)
Instance\RunningObjectTable.cs (2)
27
if (!
NativeMethodsShared
.IsWindows)
95
if (
NativeMethodsShared
.IsWindows && Ole32.GetErrorInfo(0, out IErrorInfo errorInfo) == 0 && errorInfo != null)
Logging\BaseConsoleLogger.cs (1)
265
runningWithCharacterFileType =
NativeMethodsShared
.IsWindows && ConsoleConfiguration.OutputIsScreen;
Logging\InProcessConsoleConfiguration.cs (10)
27
if (
NativeMethodsShared
.IsWindows && !Console.IsOutputRedirected)
31
IntPtr stdOut =
NativeMethodsShared
.GetStdHandle(
NativeMethodsShared
.STD_OUTPUT_HANDLE);
32
if (
NativeMethodsShared
.GetConsoleMode(stdOut, out uint consoleMode))
34
acceptAnsiColorCodes = (consoleMode &
NativeMethodsShared
.ENABLE_VIRTUAL_TERMINAL_PROCESSING) != 0;
78
if (
NativeMethodsShared
.IsWindows)
81
IntPtr stdHandle =
NativeMethodsShared
.GetStdHandle(
NativeMethodsShared
.STD_OUTPUT_HANDLE);
85
uint fileType =
NativeMethodsShared
.GetFileType(stdHandle);
88
isScreen = fileType ==
NativeMethodsShared
.FILE_TYPE_CHAR;
Logging\SimpleErrorLogger.cs (4)
27
(acceptAnsiColorCodes, _, originalConsoleMode) =
NativeMethods
.QueryIsScreenAndTryEnableAnsiColorCodes(
NativeMethods
.StreamHandleType.StdErr);
88
NativeMethods
.RestoreConsoleMode(originalConsoleMode,
NativeMethods
.StreamHandleType.StdErr);
Logging\TerminalLogger\TerminalLogger.cs (5)
265
(bool supportsAnsi, bool outputIsScreen, uint? originalConsoleMode) =
NativeMethodsShared
.QueryIsScreenAndTryEnableAnsiColorCodes();
277
(bool supportsAnsi, bool outputIsScreen, uint? originalConsoleMode) =
NativeMethodsShared
.QueryIsScreenAndTryEnableAnsiColorCodes();
367
NativeMethodsShared
.RestoreConsoleMode(originalConsoleMode);
381
NativeMethodsShared
.RestoreConsoleMode(originalConsoleMode);
547
NativeMethodsShared
.RestoreConsoleMode(_originalConsoleMode);
NamedPipeUtil.cs (1)
26
if (
NativeMethodsShared
.IsUnixLike)
Utilities\Utilities.cs (2)
502
string extensionsPath32 =
NativeMethodsShared
.IsWindows
518
string extensionsPath64 =
NativeMethodsShared
.IsWindows
Microsoft.Build.BuildCheck.UnitTests (8)
DoubleWritesAnalyzer_Tests.cs (1)
28
string projectFile = Framework.
NativeMethods
.IsWindows ? @"C:\fake\project.proj" : "/fake/project.proj";
ExecCliBuildCheck_Tests.cs (1)
94
string projectFile = Framework.
NativeMethods
.IsWindows ? @"C:\fake\project.proj" : "/fake/project.proj";
SharedOutputPathCheck_Tests.cs (6)
41
string projectFile1 = Framework.
NativeMethods
.IsWindows ? "C:\\fake1\\project1.proj" : "/fake1/project1.proj";
51
string projectFile2 = Framework.
NativeMethods
.IsWindows ? "C:\\fake2\\project2.proj" : "/fake2/project2.proj";
68
string projectFile1 = Framework.
NativeMethods
.IsWindows ? "C:\\fake\\project1.proj" : "/fake/project1.proj";
69
string projectFile2 = Framework.
NativeMethods
.IsWindows ? "C:\\fake\\project2.proj" : "/fake/project2.proj";
93
string wrongPathSeparator = Framework.
NativeMethods
.IsWindows ? "/" : "\\";
108
string projectFolder = Framework.
NativeMethods
.IsWindows ? "C:\\fake\\" : "/fake/";
Microsoft.Build.CommandLine.UnitTests (13)
AssemblyInfo.cs (1)
4
global using NativeMethodsShared = Microsoft.Build.Framework.
NativeMethods
;
XMake_Tests.cs (12)
139
parameters[1].ShouldBe(Convert.ToString(
NativeMethodsShared
.GetLogicalCoreCount()));
1244
NativeMethodsShared
.IsWindows ? @"c:\bin\msbuild.exe" : "/msbuild.exe",
1271
private readonly string _pathToArbitraryBogusFile =
NativeMethodsShared
.IsWindows // OK on 64 bit as well
1281
var msbuildParameters = "\"" + _pathToArbitraryBogusFile + "\"" + (
NativeMethodsShared
.IsWindows ? " /v:diag" : " -v:diag");
1287
output.ShouldContain(RunnerUtilities.PathToCurrentlyRunningMsBuildExe + (
NativeMethodsShared
.IsWindows ? " /v:diag " : " -v:diag ") + _pathToArbitraryBogusFile, Case.Insensitive);
1296
var msbuildParameters = "\"" + _pathToArbitraryBogusFile + "\"" + (
NativeMethodsShared
.IsWindows ? " /v:diag" : " -v:diag");
1302
if (
NativeMethodsShared
.IsWindows)
1310
output.ShouldContain(RunnerUtilities.PathToCurrentlyRunningMsBuildExe + (
NativeMethodsShared
.IsWindows ? " /v:diag " : " -v:diag ") + _pathToArbitraryBogusFile, Case.Insensitive);
1326
var msbuildParameters = "\"" + _pathToArbitraryBogusFile + "\"" + (
NativeMethodsShared
.IsWindows ? " /v:diag" : " -v:diag");
1336
output.ShouldContain(RunnerUtilities.PathToCurrentlyRunningMsBuildExe + (
NativeMethodsShared
.IsWindows ? " /v:diag " : " -v:diag ") + _pathToArbitraryBogusFile, Case.Insensitive);
2259
fileLoggerParameters = new[] { "Parameter1", "verbosity=Normal;logfile=" + (
NativeMethodsShared
.IsWindows ? "c:\\temp\\cat.log" : "/tmp/cat.log") };
3007
ProjectCollection.DisplayVersion,
NativeMethodsShared
.FrameworkName);
Microsoft.Build.Engine.OM.UnitTests (39)
AssemblyInfo.cs (1)
4
global using NativeMethodsShared = Microsoft.Build.Framework.
NativeMethods
;
Construction\ProjectRootElement_Tests.cs (1)
1772
Assert.Equal(
NativeMethodsShared
.GetCurrentDirectory(), rootElement.DirectoryPath);
Construction\SolutionFile_Tests.cs (1)
735
return usesNewParser && !
NativeMethodsShared
.IsWindows ? path.Replace('\\', '/') : path;
Construction\WhiteSpacePreservation_Tests.cs (1)
450
if (
NativeMethodsShared
.IsWindows)
Definition\DefinitionEditing_Tests.cs (9)
329
NativeMethodsShared
.IsWindows
522
NativeMethodsShared
.IsWindows ? @"c:\subdir1\**\subdir2\**\*.x?x" : "/subdir1/**/subdir2/**/*.x?x");
528
NativeMethodsShared
.IsWindows ? @"c:\subdir1\a\b\subdir2\c\i1.xyx" : "/subdir1/a/b/subdir2/c/i1.xyx")[
532
NativeMethodsShared
.IsWindows ?
1522
xml.AddImport(
NativeMethodsShared
.IsWindows ?
2252
NativeMethodsShared
.IsWindows ? @"c:\" + Guid.NewGuid().ToString() + @"\**\i1" : "/" + Guid.NewGuid().ToString() + "/**/i1");
2442
NativeMethodsShared
.IsWindows ? @"c:\subdir1\**\subdir2\**\*.x?x" : "/subdir1/**/subdir2/**/*.x?x");
2446
NativeMethodsShared
.IsWindows ? @"c:\subdir1\a\b\subdir2\c\i1.xyx" : "/subdir1/a/b/subdir2/c/i1.xyx")[0].Xml;
2449
NativeMethodsShared
.IsWindows ?
Definition\Project_Tests.cs (3)
43
private readonly int RootPrefixLength =
NativeMethodsShared
.IsWindows ? 3 : 1;
682
if (
NativeMethodsShared
.IsWindows)
2834
var itemElements =
NativeMethodsShared
.GetLogicalCoreCount() * 5;
Definition\ProjectCollection_Tests.cs (1)
409
string projectDirectory =
NativeMethodsShared
.IsWindows ? "c:\\1" : "/l";
Definition\ProjectItem_Tests.cs (12)
284
NativeMethodsShared
.IsWindows ? @"<i Include='c:\foo\bar.baz'/>" : @"<i Include='/foo/bar.baz'/>");
298
NativeMethodsShared
.IsWindows ? @"c:\foo\bar.baz" : "/foo/bar.baz",
300
Assert.Equal(
NativeMethodsShared
.IsWindows ? @"c:\" : "/", item.GetMetadataValue("RootDir"));
303
Assert.Equal(
NativeMethodsShared
.IsWindows ? @"c:\foo\" : "/foo/", item.GetMetadataValue("RelativeDir"));
304
Assert.Equal(
NativeMethodsShared
.IsWindows ? @"foo\" : "foo/", item.GetMetadataValue("Directory"));
307
NativeMethodsShared
.IsWindows ? @"c:\foo\bar.baz" : "/foo/bar.baz",
369
"<i Include='" + directory + (
NativeMethodsShared
.IsWindows ? @"\**\*'/>" : "/**/*'/>"));
371
Assert.Equal(
NativeMethodsShared
.IsWindows ? @"b\" : "b/", item.GetMetadataValue("RecursiveDir"));
414
IList<ProjectItem> items = ObjectModelHelpers.GetItemsFromFragment("<i Include='i0;" + directory + (
NativeMethodsShared
.IsWindows ? @"\**\*;i2'/>" : "/**/*;i2'/>"));
418
Assert.Equal(
NativeMethodsShared
.IsWindows ? @"b\" : "b/", items[1].GetMetadataValue("RecursiveDir"));
751
if (
NativeMethodsShared
.IsWindows)
1650
<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") + @"'/>
267
<i Include='" + (
NativeMethodsShared
.IsWindows ? @"c:\a\b.ext" : "/a/b.ext") + @"'/>
294
<i Include='" + (
NativeMethodsShared
.IsWindows ? @"c:\a\b.ext" : "/a/b.ext") + @"'/>
323
<i Include='" + (
NativeMethodsShared
.IsWindows ? @"c:\a\b.ext" : "/a/b.ext") + @"'>
Definition\ProjectProperty_Tests.cs (2)
154
string varName =
NativeMethodsShared
.IsWindows ? "username" : "USER";
177
string varName =
NativeMethodsShared
.IsWindows ? "username" : "USER";
Instance\ProjectInstance_Tests.cs (3)
893
instance.GetProperty(
NativeMethodsShared
.IsWindows ? "username" : "USER").EvaluatedValue =
918
instance.GetProperty(
NativeMethodsShared
.IsWindows ? "username" : "USER").EvaluatedValue =
940
instance.GetProperty(
NativeMethodsShared
.IsWindows ? "username" : "USER").EvaluatedValue =
Instance\ProjectItemInstance_Tests.cs (1)
751
<i Include='i1.cpp;" + (
NativeMethodsShared
.IsWindows ? @"c:\bar\i2.cpp" : "/bar/i2.cpp") + @"'>
Microsoft.Build.Engine.UnitTests (161)
AssemblyInfo.cs (1)
4
global using NativeMethodsShared = Microsoft.Build.Framework.
NativeMethods
;
BackEnd\AppHostSupport_Tests.cs (1)
27
private readonly string _dotnetHostPath =
NativeMethodsShared
.IsWindows
BackEnd\BuildManager_Tests.cs (2)
290
<Exec Command='echo What does a cat say : " + (
NativeMethodsShared
.IsWindows ? "%MOO%" : "$MOO") + @"' />
4081
MaxNodeCount =
NativeMethodsShared
.GetLogicalCoreCount(),
BackEnd\BuildRequestConfiguration_Tests.cs (1)
540
if (!
NativeMethodsShared
.IsWindows)
BackEnd\TargetUpToDateChecker_Tests.cs (6)
1042
NativeMethodsShared
.CreateFile(
1043
inputSymlink,
NativeMethodsShared
.GENERIC_READ | 0x100 /* FILE_WRITE_ATTRIBUTES */,
1044
NativeMethodsShared
.FILE_SHARE_READ, IntPtr.Zero,
NativeMethodsShared
.OPEN_EXISTING,
1045
NativeMethodsShared
.FILE_ATTRIBUTE_NORMAL |
NativeMethodsShared
.FILE_FLAG_OPEN_REPARSE_POINT,
BinaryLogger_Tests.cs (2)
480
Assert.True(
NativeMethodsShared
.MakeSymbolicLink(symlinkPath, testFile.Path, ref errorMessage), errorMessage);
481
Assert.True(
NativeMethodsShared
.MakeSymbolicLink(symlinkLvl2Path, symlinkPath, ref errorMessage), errorMessage);
ConsoleLogger_Tests.cs (4)
1966
IntPtr stdHandle =
NativeMethodsShared
.GetStdHandle(
NativeMethodsShared
.STD_OUTPUT_HANDLE);
1970
uint fileType =
NativeMethodsShared
.GetFileType(stdHandle);
1973
return fileType ==
NativeMethodsShared
.FILE_TYPE_CHAR;
Construction\SolutionFile_NewParser_Tests.cs (1)
156
return !
NativeMethodsShared
.IsWindows ? path.Replace('\\', '/') : path;
Construction\SolutionFile_OldParser_Tests.cs (7)
36
p.FullPath =
NativeMethodsShared
.IsWindows ? "c:\\foo.sln" : "/foo.sln";
58
p.FullPath =
NativeMethodsShared
.IsWindows ? "c:\\foo.sln" : "/foo.sln";
75
p.FullPath =
NativeMethodsShared
.IsWindows ? "c:\\foo.sln" : "/foo.sln";
94
p.FullPath =
NativeMethodsShared
.IsWindows ? "c:\\foo.sln" : "/foo.sln";
150
p.FullPath =
NativeMethodsShared
.IsWindows ? "c:\\foo.sln" : "/foo.sln";
611
string expectedPath3 =
NativeMethodsShared
.IsWindows ? @"ETPProjUpgradeTest\someproj3.etp" : "ETPProjUpgradeTest/someproj3.etp";
715
p.FullPath =
NativeMethodsShared
.IsWindows ? "c:\\foo.sln" : "/foo.sln";
Definition\Toolset_Tests.cs (2)
54
if (
NativeMethodsShared
.IsWindows)
209
if (
NativeMethodsShared
.IsUnixLike)
Definition\ToolsetConfigurationReader_Tests.cs (2)
566
if (
NativeMethodsShared
.IsWindows)
571
else if (
NativeMethodsShared
.IsOSX)
Definition\ToolsetReader_Tests.cs (32)
133
string v2Folder =
NativeMethodsShared
.IsWindows
135
: Path.Combine(
NativeMethodsShared
.FrameworkBasePath, "2.0");
136
string v4Folder =
NativeMethodsShared
.IsWindows
138
: Path.Combine(
NativeMethodsShared
.FrameworkBasePath, "4.0");
218
if (
NativeMethodsShared
.IsLinux)
364
string v2Folder =
NativeMethodsShared
.IsWindows
366
: Path.Combine(
NativeMethodsShared
.FrameworkBasePath, "2.0");
505
string v2Folder =
NativeMethodsShared
.IsWindows
507
: Path.Combine(
NativeMethodsShared
.FrameworkBasePath, "2.0");
752
string binPath =
NativeMethodsShared
.IsWindows ? @"c:\someBinPath" : "/someBinPath";
976
string binPath =
NativeMethodsShared
.IsWindows ? @"D:\somepath" : "/somepath";
977
string binPath2 =
NativeMethodsShared
.IsWindows ? @"D:\somepath2" : "/somepath2";
978
string fworkPath2 =
NativeMethodsShared
.IsWindows
981
string fworkPath4 =
NativeMethodsShared
.IsWindows
1091
string binPath =
NativeMethodsShared
.IsWindows ? @"D:\somepath" : "/somepath";
1092
string binPath2 =
NativeMethodsShared
.IsWindows ? @"D:\somepath2" : "/somepath2";
1164
string binPath =
NativeMethodsShared
.IsWindows ? "c:\\x" : "/x";
1255
string v2Dir =
NativeMethodsShared
.IsWindows ? "D:\\windows\\Microsoft.NET\\Framework\\v2.0.x86ret" : "/windows/Microsoft.NET/Framework/v2.0.x86ret";
1256
string v4Dir =
NativeMethodsShared
.IsWindows ? "D:\\windows\\Microsoft.NET\\Framework\\v4.0.x86ret" : "/windows/Microsoft.NET/Framework/v4.0.x86ret";
1610
string v20Dir =
NativeMethodsShared
.IsWindows ? @"D:\20\some\folder\on\disk" : "/20/some/folder/on/disk";
1611
string v35Dir =
NativeMethodsShared
.IsWindows ? @"D:\35\some\folder\on\disk" : "/35/some/folder/on/disk";
1874
string binPath =
NativeMethodsShared
.IsWindows ? @"D:\somepath" : "/somepath";
1875
string overrideBinPath =
NativeMethodsShared
.IsWindows ? @"D:\somedifferentpath" : "/somedifferentpath";
1920
string binPath =
NativeMethodsShared
.IsWindows ? @"D:\somepath" : "/somepath";
1965
string binPath =
NativeMethodsShared
.IsWindows ? @"D:\somepath" : "/somepath";
1966
string overrideBinPath =
NativeMethodsShared
.IsWindows ? @"D:\someotherpath" : "/someotherpath";
2057
string binPath =
NativeMethodsShared
.IsWindows ? @"D:\somedifferentpath" : "/somedifferentpath";
2099
string binPath =
NativeMethodsShared
.IsWindows ? @"D:\somepath" : "/somepath";
2339
string overridePath =
NativeMethodsShared
.IsWindows ? "c:\\TaskOverridePath" : "/TaskOverridePath";
2631
string binPathConfig =
NativeMethodsShared
.IsWindows ?
2634
string toolsPathConfig =
NativeMethodsShared
.IsWindows ?
2670
string expectedToolsPath =
NativeMethodsShared
.IsWindows
Definition\ToolsetRegistryReader_Tests.cs (10)
100
if (
NativeMethodsShared
.IsUnixLike)
181
string xdir =
NativeMethodsShared
.IsWindows ? "c:\\xxx" : "/xxx";
204
string xdir =
NativeMethodsShared
.IsWindows ? "c:\\xxx" : "/xxx";
205
string ydir =
NativeMethodsShared
.IsWindows ? "c:\\yyy" : "/yyy";
263
string xdir =
NativeMethodsShared
.IsWindows ? "c:\\xxx" : "/xxx";
264
string ydir =
NativeMethodsShared
.IsWindows ? "c:\\yyy" : "/yyy";
319
string xdir =
NativeMethodsShared
.IsWindows ? "c:\\xxx" : "/xxx";
354
string xdir =
NativeMethodsShared
.IsWindows ? "c:\\xxx" : "/xxx";
394
string xdir =
NativeMethodsShared
.IsWindows ? "c:\\xxx" : "/xxx";
484
if (
NativeMethodsShared
.IsUnixLike)
Definition\ToolsVersion_Tests.cs (18)
33
string dir =
NativeMethodsShared
.IsWindows ? "c:\\directory1\\directory2" : "/directory1/directory2";
34
string overrideDir =
NativeMethodsShared
.IsWindows ? "c:\\msbuildoverridetasks" : "/msbuildoverridetasks";
159
NativeMethodsShared
.IsWindows ? "c:\\directory1\\directory2" : "/directory1/directory2",
240
string dir =
NativeMethodsShared
.IsWindows ? "c:\\directory1\\directory2" : "/directory1/directory2";
241
string overrideDir =
NativeMethodsShared
.IsWindows ? "c:\\msbuildoverridetasks" : "/msbuildoverridetasks";
926
NativeMethodsShared
.IsWindows ? "c:\\inline" : "/inline",
993
new DefaultTasksFile(
NativeMethodsShared
.IsWindows
1002
new DefaultTasksFile(
NativeMethodsShared
.IsWindows
1008
new DefaultTasksFile(
NativeMethodsShared
.IsWindows
1014
new DefaultTasksFile(
NativeMethodsShared
.IsWindows
1020
new DefaultTasksFile(
NativeMethodsShared
.IsWindows
1026
new DefaultTasksFile(
NativeMethodsShared
.IsWindows
1032
new DefaultTasksFile(
NativeMethodsShared
.IsWindows
1040
new DefaultTasksFile(
NativeMethodsShared
.IsWindows
1048
new DefaultTasksFile(
NativeMethodsShared
.IsWindows
1054
new DefaultTasksFile(
NativeMethodsShared
.IsWindows
1067
new DefaultTasksFile(
NativeMethodsShared
.IsWindows
1076
new DefaultTasksFile(
NativeMethodsShared
.IsWindows
Evaluation\Evaluator_Tests.cs (15)
174
string fooPath =
NativeMethodsShared
.IsWindows ? @"c:\temp\foo.import" : "/temp/foo.import";
175
string barPath =
NativeMethodsShared
.IsWindows ? @"c:\temp\bar.import" : "/temp/bar.import";
1363
string targets1FileName =
NativeMethodsShared
.IsWindows ? @"c:\a\t1.targets" : "/a/t1.targets";
1364
string aDirName =
NativeMethodsShared
.IsWindows ? @"c:\a\" : "/a/";
1365
string targets2FileName =
NativeMethodsShared
.IsWindows ? @"c:\a\b\t2.targets" : "/a/b/t2.targets";
1366
string bDirName =
NativeMethodsShared
.IsWindows ? @"c:\a\b\" : "/a/b/";
1367
string targets3FileName =
NativeMethodsShared
.IsWindows ? @"c:\t3.targets" : "/t3.targets";
1368
string rootDirName =
NativeMethodsShared
.IsWindows ? @"c:\" : "/";
1369
string aProjName =
NativeMethodsShared
.IsWindows ? @"c:\a\p.proj" : "/a/p.proj";
2432
string msbuildPath =
NativeMethodsShared
.IsWindows ?
2564
string msbuildPath =
NativeMethodsShared
.IsWindows ? Path.Combine(expected, "MSBuild") : "MSBuild";
2799
string file =
NativeMethodsShared
.IsWindows ? @"c:\foo\bar.csproj" : "/foo/bar.csproj";
2818
string file =
NativeMethodsShared
.IsWindows ? @"c:\bar.csproj" : "/bar.csproj";
2819
string dir =
NativeMethodsShared
.IsWindows ? @"c:\" : "/";
3858
if (
NativeMethodsShared
.IsUnixLike)
Evaluation\Expander_Tests.cs (11)
43
private static readonly string s_rootPathPrefix =
NativeMethodsShared
.IsWindows ? "C:\\" : Path.VolumeSeparatorChar.ToString();
1415
NativeMethodsShared
.IsWindows ? @"subdir1\engine.dll" : "subdir1/engine.dll", project.FullPath);
1419
NativeMethodsShared
.IsWindows ? @"subdir2\tasks.dll" : "subdir2/tasks.dll", project.FullPath);
1905
string envVar =
NativeMethodsShared
.IsWindows ? "TEMP" : "USER";
3879
string envVar =
NativeMethodsShared
.IsWindows ? "TEMP" : "USER";
3903
string envVar =
NativeMethodsShared
.IsWindows ? "TEMP" : "USER";
3927
string envVar =
NativeMethodsShared
.IsWindows ? "TEMP" : "USER";
3951
string envVar =
NativeMethodsShared
.IsWindows ? "TEMP" : "USER";
4343
if (
NativeMethodsShared
.IsWindows)
4350
if (
NativeMethodsShared
.IsWindows)
4355
if (!
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)
607
if (!
NativeMethodsShared
.IsWindows)
Evaluation\ItemSpec_Tests.cs (1)
44
var absoluteRootPath =
NativeMethodsShared
.IsWindows
Evaluation\ProjectRootElementCache_Tests.cs (2)
71
string rootedPath =
NativeMethodsShared
.IsUnixLike ? "/foo" : "c:\\foo";
84
string projectPath =
NativeMethodsShared
.IsUnixLike ? "/foo" : "c:\\foo";
Evaluation\SimpleProjectRootElementCache_Tests.cs (11)
32
string projectFile =
NativeMethodsShared
.IsUnixLike ? "/foo" : "c:\\foo";
33
string projectFileToCache =
NativeMethodsShared
.IsUnixLike ? "/foo" : "c:\\foo";
46
string projectFile =
NativeMethodsShared
.IsUnixLike ? "/foo" : "c:\\foo";
47
string projectFileToCache =
NativeMethodsShared
.IsUnixLike ? "/Foo" : "c:\\Foo";
60
string projectFile =
NativeMethodsShared
.IsUnixLike ? "/foo" : "c:\\foo";
61
string projectFileToCache =
NativeMethodsShared
.IsUnixLike ? "/foo" : "c:\\foo";
78
string projectFile =
NativeMethodsShared
.IsUnixLike ? "/foo" : "c:\\foo";
79
string projectFileToCache =
NativeMethodsShared
.IsUnixLike ? "/Foo" : "c:\\Foo";
96
string projectFile =
NativeMethodsShared
.IsUnixLike ? "/foo" : "c:\\foo";
110
string projectFile =
NativeMethodsShared
.IsUnixLike ? "/foo" : "c:\\foo";
111
string projectFileToCache =
NativeMethodsShared
.IsUnixLike ? "/bar" : "c:\\bar";
Globbing\MSBuildGlob_Tests.cs (6)
40
var globRoot =
NativeMethodsShared
.IsWindows ? @"c:\a" : "/a";
116
var globRoot =
NativeMethodsShared
.IsWindows ? @"c:\a" : "/a";
137
var globRoot =
NativeMethodsShared
.IsWindows ? @"c:\a" : "/a";
157
var globRoot =
NativeMethodsShared
.IsWindows ? @"c:\a" : "/a";
213
if (
NativeMethodsShared
.IsUnixLike)
360
return
NativeMethodsShared
.IsWindows ? normalizedPath.Replace("\\\\", "\\") : normalizedPath;
Graph\IsolateProjects_Tests.cs (2)
137
if (
NativeMethodsShared
.IsOSX)
145
var disableInProcNode = !
NativeMethodsShared
.IsOSX;
Graph\ParallelWorkSet_Tests.cs (4)
69
DegreeOfParallelism =
NativeMethodsShared
.GetLogicalCoreCount(),
97
DegreeOfParallelism =
NativeMethodsShared
.GetLogicalCoreCount()
112
DegreeOfParallelism =
NativeMethodsShared
.GetLogicalCoreCount(),
176
DegreeOfParallelism =
NativeMethodsShared
.GetLogicalCoreCount(),
ProjectCache\ProjectCacheTests.cs (8)
680
var referenceNumbers = Enumerable.Range(2,
NativeMethodsShared
.GetLogicalCoreCount()).ToArray();
1413
MaxNodeCount =
NativeMethodsShared
.GetLogicalCoreCount(),
1469
var referenceNumbers = Enumerable.Range(2,
NativeMethodsShared
.GetLogicalCoreCount() * 2).ToArray();
1486
MaxNodeCount =
NativeMethodsShared
.GetLogicalCoreCount(),
1532
var referenceNumbers = Enumerable.Range(2,
NativeMethodsShared
.GetLogicalCoreCount() * 2).ToArray();
1546
MaxNodeCount =
NativeMethodsShared
.GetLogicalCoreCount(),
1596
var projectPaths = Enumerable.Range(0,
NativeMethodsShared
.GetLogicalCoreCount())
1626
MaxNodeCount =
NativeMethodsShared
.GetLogicalCoreCount()
TerminalLogger_Tests.cs (3)
144
private readonly string _projectFile =
NativeMethods
.IsUnixLike ? "/src/project.proj" : @"C:\src\project.proj";
145
private readonly string _projectFile2 =
NativeMethods
.IsUnixLike ? "/src/project2.proj" : @"C:\src\project2.proj";
146
private readonly string _projectFileWithNonAnsiSymbols =
NativeMethods
.IsUnixLike ? "/src/проектТерминал/㐇𠁠𪨰𫠊𫦠𮚮⿕.proj" : @"C:\src\проектТерминал\㐇𠁠𪨰𫠊𫦠𮚮⿕.proj";
Utilities_Tests.cs (1)
84
MSBuildApp.Execute([ @"c:\bin\msbuild.exe", '"' + inputFile.Path + '"', '"' + (
NativeMethodsShared
.IsUnixLike ? "-pp:" : "/pp:") + outputFile.Path + '"']));
Microsoft.Build.Framework (88)
BuildEnvironmentHelper.cs (12)
133
if (!
NativeMethods
.IsWindows)
165
if (
NativeMethods
.IsWindows &&
239
if (
NativeMethods
.IsWindows &&
369
NativeMethods
.ProcessorArchitecture ==
NativeMethods
.ProcessorArchitectures.X64 ? "amd64" :
370
NativeMethods
.ProcessorArchitecture ==
NativeMethods
.ProcessorArchitectures.ARM64 ? "arm64" : string.Empty,
590
MSBuildToolsDirectoryRoot =
NativeMethods
.ProcessorArchitecture switch
592
NativeMethods
.ProcessorArchitectures.X86 => CurrentMSBuildToolsDirectory,
593
NativeMethods
.ProcessorArchitectures.X64 or
NativeMethods
.ProcessorArchitectures.ARM64
595
_ => throw new InternalErrorException("Unknown processor architecture " +
NativeMethods
.ProcessorArchitecture),
CommunicationsUtilities.cs (1)
218
if (
NativeMethods
.IsWindows)
Constants.cs (2)
31
internal static readonly string DotnetProcessName =
NativeMethods
.IsWindows ? "dotnet.exe" : "dotnet";
46
internal static readonly string MSBuildExecutableName =
NativeMethods
.IsWindows ? $"{MSBuildAppName}.exe" : MSBuildAppName;
EncodingUtilities.cs (3)
58
if (
NativeMethods
.IsWindows)
64
s_currentOemEncoding = Encoding.GetEncoding(
NativeMethods
.GetOEMCP());
224
if (!
NativeMethods
.IsWindows)
FileSystem\FileSystems.cs (1)
17
if (
NativeMethods
.IsWindows)
FileSystem\WindowsFileSystem.cs (5)
61
throw new PathTooLongException(SR.FormatPathTooLong(path,
NativeMethods
.MaxPath));
64
return
NativeMethods
.DirectoryExistsWindows(path);
78
return
NativeMethods
.FileOrDirectoryExistsWindows(path);
83
var fileLastWriteTime =
NativeMethods
.GetLastWriteFileUtcTime(path);
91
NativeMethods
.GetLastWriteDirectoryUtcTime(path, out var directoryLastWriteTime);
FileUtilities.cs (11)
234
=> path.Length >=
NativeMethods
.MaxPath; // >= not > because MAX_PATH assumes a trailing null
240
=>
NativeMethods
.IsUnixLike && path.IndexOf(WindowsDirectorySeparator) >= 0;
246
=>
NativeMethods
.IsWindows && path.IndexOf(UnixDirectorySeparator) >= 0;
430
if (
NativeMethods
.GetLastWriteDirectoryUtcTime(directoryPath, out lastModifiedTime))
772
if (
NativeMethods
.IsWindows || string.IsNullOrEmpty(value)
793
if (
NativeMethods
.IsWindows || value.IsEmpty)
874
if (
NativeMethods
.IsWindows)
1002
if (
NativeMethods
.IsWindows && !EndsWithSlash(fullPath))
1454
bool hasMaxPath =
NativeMethods
.HasMaxPath;
1455
int maxPath =
NativeMethods
.MaxPath;
1457
return hasMaxPath && !IsRootedNoThrow(path) &&
NativeMethods
.GetCurrentDirectory().Length + path.Length + 1 /* slash */ >= maxPath;
ItemSpecModifiers.cs (1)
547
if (
NativeMethods
.IsWindows)
MSBuildNameIgnoreCaseComparer.cs (6)
25
private static readonly
NativeMethods
.ProcessorArchitectures s_runningProcessorArchitecture =
NativeMethods
.ProcessorArchitecture;
75
if ((s_runningProcessorArchitecture !=
NativeMethods
.ProcessorArchitectures.IA64)
76
&& (s_runningProcessorArchitecture !=
NativeMethods
.ProcessorArchitectures.ARM))
123
if ((s_runningProcessorArchitecture !=
NativeMethods
.ProcessorArchitectures.IA64)
124
&& (s_runningProcessorArchitecture !=
NativeMethods
.ProcessorArchitectures.ARM))
MultiProcessTaskEnvironmentDriver.cs (2)
34
get => new AbsolutePath(
NativeMethods
.GetCurrentDirectory(), ignoreRootedCheck: true);
35
set =>
NativeMethods
.SetCurrentDirectory(value.Value);
NativeMethods.cs (2)
1184
bool success =
NativeMethods
.GetFileAttributesEx(path, 0, ref data);
1186
if (success && (data.fileAttributes &
NativeMethods
.FILE_ATTRIBUTE_DIRECTORY) == 0)
PathHelpers\AbsolutePath.cs (1)
29
private static readonly StringComparer s_pathComparer =
NativeMethods
.IsFileSystemCaseSensitive ? StringComparer.Ordinal : StringComparer.OrdinalIgnoreCase;
Utilities\FileMatcher.cs (5)
1063
if (
NativeMethods
.IsLinux && recursionState.SearchData.DirectoryPattern != null)
1204
using (var matchFileExpression = new ReuseableStringBuilder(FileSpecRegexMinLength +
NativeMethods
.MAX_PATH))
1257
bool isUncPath =
NativeMethods
.IsWindows && fixedDir.Length > 1
2273
if (
NativeMethods
.IsWindows &&
2595
var maxTasks = Math.Max(1,
NativeMethods
.GetLogicalCoreCount() / 2);
Utilities\FrameworkLocationHelper.cs (34)
93
internal static string dotNetFrameworkVersionFolderPrefixV11 =
NativeMethods
.IsWindows ? "v1.1" : "1.1"; // v1.1 is for Everett.
98
internal static string dotNetFrameworkVersionFolderPrefixV20 =
NativeMethods
.IsWindows ? "v2.0" : "2.0"; // v2.0 is for Whidbey.
102
internal static string dotNetFrameworkVersionFolderPrefixV30 =
NativeMethods
.IsWindows ? "v3.0" : "3.0"; // v3.0 is for WinFx.
116
internal static string dotNetFrameworkVersionFolderPrefixV35 =
NativeMethods
.IsWindows ? "v3.5" : "3.5"; // v3.5 is for Orcas.
122
internal static string dotNetFrameworkVersionFolderPrefixV40 =
NativeMethods
.IsWindows ? "v4.0" : "4.0";
123
internal static string dotNetFrameworkVersionFolderPrefixV45 =
NativeMethods
.IsWindows ? "v4.5" : "4.5";
444
return
NativeMethods
.IsUnixLike
445
? Path.Combine(
NativeMethods
.FrameworkBasePath, dotNetFrameworkVersionFolderPrefixV11)
454
return
NativeMethods
.IsUnixLike
455
? Path.Combine(
NativeMethods
.FrameworkBasePath, dotNetFrameworkVersionFolderPrefixV20)
464
return
NativeMethods
.IsUnixLike
465
? Path.Combine(
NativeMethods
.FrameworkBasePath, dotNetFrameworkVersionFolderPrefixV30)
474
return
NativeMethods
.IsUnixLike
475
? Path.Combine(
NativeMethods
.FrameworkBasePath, dotNetFrameworkVersionFolderPrefixV35)
484
return
NativeMethods
.IsUnixLike
485
? Path.Combine(
NativeMethods
.FrameworkBasePath, dotNetFrameworkVersionFolderPrefixV40)
494
return
NativeMethods
.IsUnixLike
495
? Path.Combine(
NativeMethods
.FrameworkBasePath, dotNetFrameworkVersionFolderPrefixV45)
504
return
NativeMethods
.IsUnixLike
505
? Path.Combine(
NativeMethods
.FrameworkBasePath, dotNetFrameworkVersionFolderPrefixV11)
514
return
NativeMethods
.IsUnixLike
515
? Path.Combine(
NativeMethods
.FrameworkBasePath, dotNetFrameworkVersionFolderPrefixV20)
538
if (!
NativeMethods
.IsWindows)
540
s_fallbackDotNetFrameworkSdkInstallPath =
NativeMethods
.FrameworkCurrentPath;
588
if (
NativeMethods
.IsWindows)
635
if (
NativeMethods
.IsWindows)
829
if (!
NativeMethods
.IsWindows)
836
var frameworkPath = Path.Combine(
NativeMethods
.FrameworkBasePath, prefix ?? string.Empty);
986
combinedPath =
NativeMethods
.IsWindows
988
: Path.Combine(
NativeMethods
.FrameworkBasePath, "xbuild-frameworks");
1196
dotNetFrameworkVersionFolderPrefix:
NativeMethods
.IsWindows ? "v4.0" : "v4.5",
1481
if (
NativeMethods
.IsUnixLike)
1483
string frameworkPath =
NativeMethods
.FrameworkBasePath;
1572
if (
NativeMethods
.IsWindows)
Utilities\ProcessExtensions.cs (2)
25
if (
NativeMethods
.IsWindows)
29
NativeMethods
.KillTree(process.Id);
Microsoft.Build.Framework.UnitTests (51)
AssemblyInfo.cs (1)
4
global using NativeMethodsShared = Microsoft.Build.Framework.
NativeMethods
;
FileClassifier_Tests.cs (4)
31
var volume =
NativeMethodsShared
.IsWindows ? @"X:\" : "/home/usr";
45
var volume =
NativeMethodsShared
.IsWindows ? @"X:\" : "/home/usr";
63
var volume =
NativeMethodsShared
.IsWindows ? @"X:\" : "/home/usr";
66
if (
NativeMethodsShared
.IsLinux)
FileMatcher_Tests.cs (29)
157
if (!
NativeMethodsShared
.IsLinux)
261
ExpectNoMatches =
NativeMethodsShared
.IsLinux
283
ExpectNoMatches =
NativeMethodsShared
.IsLinux,
301
ExpectNoMatches =
NativeMethodsShared
.IsLinux,
322
ExpectNoMatches =
NativeMethodsShared
.IsLinux,
341
ExpectNoMatches =
NativeMethodsShared
.IsLinux,
358
ExpectNoMatches =
NativeMethodsShared
.IsLinux,
450
ExpectNoMatches =
NativeMethodsShared
.IsLinux,
474
ExpectNoMatches =
NativeMethodsShared
.IsLinux,
496
ExpectNoMatches =
NativeMethodsShared
.IsLinux,
512
ExpectNoMatches =
NativeMethodsShared
.IsLinux,
1002
if (
NativeMethodsShared
.IsWindows)
1016
NativeMethodsShared
.IsWindows ? "f:\\dir1\\dir2\\file.txt" : "/dir1/dir2/file.txt",
1017
NativeMethodsShared
.IsWindows ? "f:\\dir1\\dir2\\file.txt" : "/dir1/dir2/file.txt",
1470
string[] strings = new string[1] {
NativeMethodsShared
.IsWindows ? "c:\\1.file" : "/1.file" };
1471
strings = FileMatcher.RemoveProjectDirectory(strings,
NativeMethodsShared
.IsWindows ? "c:\\" : "/").ToArray();
1474
strings = new string[1] {
NativeMethodsShared
.IsWindows ? "c:\\directory\\1.file" : "/directory/1.file" };
1475
strings = FileMatcher.RemoveProjectDirectory(strings,
NativeMethodsShared
.IsWindows ? "c:\\" : "/").ToArray();
1476
Assert.Equal(strings[0],
NativeMethodsShared
.IsWindows ? "directory\\1.file" : "directory/1.file");
1478
strings = new string[1] {
NativeMethodsShared
.IsWindows ? "c:\\directory\\1.file" : "/directory/1.file" };
1479
strings = FileMatcher.RemoveProjectDirectory(strings,
NativeMethodsShared
.IsWindows ? "c:\\directory" : "/directory").ToArray();
1482
strings = new string[1] {
NativeMethodsShared
.IsWindows ? "c:\\1.file" : "/1.file" };
1483
strings = FileMatcher.RemoveProjectDirectory(strings,
NativeMethodsShared
.IsWindows ? "c:\\directory" : "/directory").ToArray();
1484
Assert.Equal(strings[0],
NativeMethodsShared
.IsWindows ? "c:\\1.file" : "/1.file");
1486
strings = new string[1] {
NativeMethodsShared
.IsWindows ? "c:\\directorymorechars\\1.file" : "/directorymorechars/1.file" };
1487
strings = FileMatcher.RemoveProjectDirectory(strings,
NativeMethodsShared
.IsWindows ? "c:\\directory" : "/directory").ToArray();
1488
Assert.Equal(strings[0],
NativeMethodsShared
.IsWindows ? "c:\\directorymorechars\\1.file" : "/directorymorechars/1.file");
1490
if (
NativeMethodsShared
.IsWindows)
1873
if (
NativeMethodsShared
.IsUnixLike)
FileUtilities_Tests.cs (17)
52
string itemSpec =
NativeMethodsShared
.IsWindows ? @"c:\foo.txt" : "/foo.txt";
53
string itemSpecDir =
NativeMethodsShared
.IsWindows ? @"c:\" : "/";
73
string projectPath =
NativeMethodsShared
.IsWindows ? @"c:\abc\goo.proj" : @"/abc/goo.proj";
74
string projectPathDir =
NativeMethodsShared
.IsWindows ? @"c:\abc\" : @"/abc/";
91
if (
NativeMethodsShared
.IsWindows)
246
Assert.Equal(
NativeMethodsShared
.IsWindows ? @"c:\" : "/", FileUtilities.GetDirectory(
NativeMethodsShared
.IsWindows ? @"c:\" : "/"));
247
Assert.Equal(
NativeMethodsShared
.IsWindows ? @"c:\" : "/", FileUtilities.GetDirectory(
NativeMethodsShared
.IsWindows ? @"c:\foo" : "/foo"));
248
Assert.Equal(
NativeMethodsShared
.IsWindows ? @"c:" : "/", FileUtilities.GetDirectory(
NativeMethodsShared
.IsWindows ? @"c:" : "/"));
531
var isWindows =
NativeMethodsShared
.IsWindows;
608
if (
NativeMethodsShared
.IsWindows)
619
if (
NativeMethodsShared
.IsWindows)
665
return !
NativeMethodsShared
.IsWindows ||
668
NativeMethodsShared
.IsMaxPathLegacyWindows();
997
string root =
NativeMethodsShared
.IsWindows ? @"c:\" : "/";
Microsoft.Build.Tasks.Core (56)
AssemblyDependency\AssemblyInformation.cs (1)
245
if (!
NativeMethodsShared
.IsWindows)
AssemblyDependency\AssemblyMetadata.cs (1)
30
ScatterFiles =
NativeMethodsShared
.IsWindows ? import.Files : null;
AssemblyDependency\Reference.cs (1)
514
else if (
NativeMethodsShared
.IsWindows)
AssemblyDependency\ResolveAssemblyReference.cs (1)
3306
p =>
NativeMethodsShared
.GetLastWriteFileUtcTime(p),
AssemblyFoldersEx.cs (1)
80
if (!
NativeMethodsShared
.IsWindows)
AssemblyInfo.cs (1)
4
global using NativeMethodsShared = Microsoft.Build.Framework.
NativeMethods
;
CommunicationsUtilities.cs (2)
287
if (includeSessionId &&
NativeMethodsShared
.IsWindows)
583
if (!
NativeMethodsShared
.IsWindows)
Copy.cs (3)
44
private static readonly int DefaultCopyParallelism =
NativeMethodsShared
.GetLogicalCoreCount() > 4 ? 6 : 4;
354
TryCopyViaLink(SymbolicLinkComment, MessageImportance.Normal, sourceFileState, destinationFileState, out symbolicLinkCreated, ref errorMessage, (source, destination, errMessage) =>
NativeMethodsShared
.MakeSymbolicLink(destination, source, ref errorMessage));
357
if (!
NativeMethodsShared
.IsWindows)
Exec.cs (7)
74
if (
NativeMethodsShared
.IsUnixLike)
213
if (!
NativeMethodsShared
.IsUnixLike)
258
if (!
NativeMethodsShared
.IsUnixLike)
501
if (
NativeMethodsShared
.IsWindows)
578
if (
NativeMethodsShared
.IsUnixLike)
593
if (
NativeMethodsShared
.IsWindows)
654
protected override string ToolName =>
NativeMethodsShared
.IsWindows ? "cmd.exe" : "sh";
FileState.cs (11)
91
if (
NativeMethodsShared
.IsWindows)
99
NativeMethodsShared
.SetThreadErrorMode(1 /* ErrorModes.SEM_FAILCRITICALERRORS */, out oldMode);
104
if (
NativeMethodsShared
.IsWindows)
106
var data = new
NativeMethodsShared
.WIN32_FILE_ATTRIBUTE_DATA();
107
bool success =
NativeMethodsShared
.GetFileAttributesEx(_filename, 0, ref data);
120
&& _filename.Length <=
NativeMethodsShared
.MaxPath)
130
NativeMethodsShared
.ThrowExceptionForErrorCode(error);
135
IsDirectory = (data.fileAttributes &
NativeMethodsShared
.FILE_ATTRIBUTE_DIRECTORY) != 0;
137
&& (data.fileAttributes &
NativeMethodsShared
.FILE_ATTRIBUTE_READONLY) != 0;
178
if (
NativeMethodsShared
.IsWindows)
180
NativeMethodsShared
.SetThreadErrorMode(oldMode, out _);
GenerateApplicationManifest.cs (1)
115
if (!
NativeMethodsShared
.IsWindows)
GenerateDeploymentManifest.cs (1)
157
if (!
NativeMethodsShared
.IsWindows)
GenerateLauncher.cs (1)
45
if (!
NativeMethodsShared
.IsWindows)
GenerateManifestBase.cs (1)
275
if (!
NativeMethodsShared
.IsWindows)
GenerateResource.cs (7)
1510
DateTime outputTime =
NativeMethodsShared
.GetLastWriteFileUtcTime(outputFilePath);
1520
DateTime sourceTime =
NativeMethodsShared
.GetLastWriteFileUtcTime(sourceFilePath);
1566
DateTime linkedFileTime =
NativeMethodsShared
.GetLastWriteFileUtcTime(linkedFilePath);
1653
DateTime sourceTime =
NativeMethodsShared
.GetLastWriteFileUtcTime(Sources[0].ItemSpec);
1654
DateTime outputTime =
NativeMethodsShared
.GetLastWriteFileUtcTime(StronglyTypedFileName);
1712
DateTime time =
NativeMethodsShared
.GetLastWriteFileUtcTime(input.ItemSpec);
2825
if (!
NativeMethodsShared
.HasMaxPath)
GetInstalledSDKLocations.cs (1)
127
if (!
NativeMethodsShared
.IsWindows)
GetSDKReferenceFiles.cs (1)
230
if (!
NativeMethodsShared
.IsWindows)
ManifestUtil\SecurityUtil.cs (1)
869
if (
NativeMethodsShared
.IsWindows && (toolPath == null || !FileSystems.Default.FileExists(toolPath)))
NamedPipeUtil.cs (1)
26
if (
NativeMethodsShared
.IsUnixLike)
NativeMethods.cs (6)
808
if (
NativeMethodsShared
.IsWindows)
841
if (
NativeMethodsShared
.IsWindows)
992
if (
NativeMethodsShared
.IsWindows)
1246
private static readonly string s_gacPath = Path.Combine(
NativeMethodsShared
.FrameworkBasePath, "gac");
1292
if (
NativeMethodsShared
.IsWindows)
1352
if (
NativeMethodsShared
.IsWindows)
NodePipeClient.cs (1)
18
private static readonly bool s_useHandhakeTimeout = !
NativeMethodsShared
.IsWindows;
NodePipeServer.cs (1)
32
private static readonly int s_handshakeTimeout =
NativeMethodsShared
.IsWindows ? 0 : 60_000;
ResolveSDKReference.cs (1)
272
if (!
NativeMethodsShared
.IsWindows)
SignFile.cs (1)
47
if (!
NativeMethodsShared
.IsWindows)
SystemState.cs (1)
667
return lastModified != DateTime.MinValue && lastModified !=
NativeMethodsShared
.MinFileDate;
Unzip.cs (1)
269
if (mode != UnixFileMode.None && !
NativeMethodsShared
.IsWindows)
Microsoft.Build.Tasks.UnitTests (104)
AddToWin32Manifest_Tests.cs (1)
186
NativeMethodsShared
.FreeLibrary(hModule);
AssemblyDependency\Miscellaneous.cs (4)
146
if (
NativeMethodsShared
.IsWindows)
222
if (
NativeMethodsShared
.IsWindows)
283
if (
NativeMethodsShared
.IsWindows)
332
if (
NativeMethodsShared
.IsWindows)
AssemblyDependency\ResolveAssemblyReferenceTestFixture.cs (1)
188
protected static readonly string s_rootPathPrefix =
NativeMethodsShared
.IsWindows ? "C:\\" : Path.VolumeSeparatorChar.ToString();
AssemblyInfo.cs (1)
4
global using NativeMethodsShared = Microsoft.Build.Framework.
NativeMethods
;
AssignLinkMetadata_Tests.cs (1)
136
var item = GetParentedTaskItem(
NativeMethodsShared
.IsUnixLike
AssignTargetPath_Tests.cs (12)
24
{ new TaskItem(
NativeMethodsShared
.IsWindows ? @"c:\bin2\abc.efg" : "/bin2/abc.efg") };
25
t.RootFolder =
NativeMethodsShared
.IsWindows ? @"c:\bin" : "/bin";
29
t.AssignedFiles[0].ItemSpec.ShouldBe(
NativeMethodsShared
.IsWindows ? @"c:\bin2\abc.efg" : "/bin2/abc.efg");
40
{ new TaskItem(
NativeMethodsShared
.IsWindows ? @"c:\f1\f2\file.txt" : "/f1/f2/file.txt") };
41
t.RootFolder =
NativeMethodsShared
.IsWindows ? @"c:\f1\f2" : "/f1/f2";
57
NativeMethodsShared
.IsWindows ? @"d:\f1\f2\f3\f4\file.txt" : "/f1/f2/f3/f4/file.txt")
63
t.RootFolder =
NativeMethodsShared
.IsWindows ? @"c:\f1" : "/x1";
79
NativeMethodsShared
.IsWindows ? @"c:\f1\f2\f3\f4\file.txt" : "/f1/f2/f3/f4/file.txt")
81
t.RootFolder =
NativeMethodsShared
.IsWindows ? @"c:\f1\f2" : "/f1/f2";
85
t.AssignedFiles[0].GetMetadata("TargetPath").ShouldBe(
NativeMethodsShared
.IsWindows ? @"f3\f4\file.txt" : "f3/f4/file.txt");
105
itemSpec:
NativeMethodsShared
.IsWindows ? @"c:\f1\f2\file.txt" : "/f1/f2/file.txt",
108
t.RootFolder =
NativeMethodsShared
.IsWindows ? @"c:\f1\f2" : "/f1/f2";
CodeTaskFactoryEmbeddedFileInBinlogTestHelper.cs (2)
71
projectDirectoryPath =
NativeMethodsShared
.IsWindows ? projectDirectoryPath.Replace(":\\", "\\") : projectDirectoryPath.Replace("/", "\\");
123
projectDirectory =
NativeMethodsShared
.IsWindows ? projectDirectory.Replace(":\\", "\\") : projectDirectory.Replace("/", "\\");
CombinePath_Tests.cs (11)
47
string path1 =
NativeMethodsShared
.IsWindows ? @"c:\ghi.txt" : "/ghi.txt";
48
string path2 =
NativeMethodsShared
.IsWindows ? @"d:\jkl\mno.txt" : "/jkl/mno.txt";
50
string pathsToMatch = string.Format(
NativeMethodsShared
.IsWindows ? @"
59
t.Paths =
NativeMethodsShared
.IsWindows
76
t.BasePath =
NativeMethodsShared
.IsWindows ? @"c:\abc\def" : "/abc/def";
96
t.BasePath =
NativeMethodsShared
.IsWindows ? @"\\fileserver\public" : "/rootdir/public";
97
string path1 =
NativeMethodsShared
.IsWindows ? @"c:\ghi.txt" : "/ghi.txt";
98
string path2 =
NativeMethodsShared
.IsWindows ? @"d:\jkl\mno.txt" : "/jkl/mno.txt";
100
string pathsToMatch = string.Format(
NativeMethodsShared
.IsWindows ? @"
108
t.Paths =
NativeMethodsShared
.IsWindows
126
if (
NativeMethodsShared
.IsWindows)
Copy_Tests.cs (5)
1151
(!
NativeMethodsShared
.IsLinux || isUseHardLinks);
1406
if (
NativeMethodsShared
.IsWindows)
1815
string invalidFile =
NativeMethodsShared
.IsUnixLike ? Path.Combine(temp, "!@#$%^&*()|") : "!@#$%^&*()|";
1847
Assert.False(
NativeMethodsShared
.IsUnixLike ? !success : success);
1853
if (
NativeMethodsShared
.IsUnixLike)
Exec_Tests.cs (26)
146
Exec exec = PrepareExec(
NativeMethodsShared
.IsWindows ? "xcopy thisisanonexistentfile" : "cp thisisanonexistentfile thatisanonexistentfile");
150
Assert.Equal(
NativeMethodsShared
.IsWindows ? 4 : 1, exec.ExitCode);
152
if (!
NativeMethodsShared
.IsWindows)
162
int expectedExitCode =
NativeMethodsShared
.IsWindows ? -1 : 137;
164
Exec exec = PrepareExec(
NativeMethodsShared
.IsWindows ? ":foo \n goto foo" : "while true; do sleep 1; done");
194
Exec exec = PrepareExec(
NativeMethodsShared
.IsWindows ? ":foo \n goto foo" : "while true; do sleep 1; done");
208
exec.ExitCode.ShouldBe(
NativeMethodsShared
.IsWindows ? -1 : 137);
237
var cmdLine =
NativeMethodsShared
.IsWindows
265
var cmdLine =
NativeMethodsShared
.IsWindows
289
Exec exec = PrepareExec(
NativeMethodsShared
.IsWindows ? "echo [%cd%]" : "echo [$PWD]");
290
string working = !
NativeMethodsShared
.IsWindows ? "/usr/lib" :
322
Directory.SetCurrentDirectory(
NativeMethodsShared
.IsWindows ?
325
Exec exec = PrepareExec(
NativeMethodsShared
.IsWindows ? "echo [%cd%]" : "echo [$PWD]");
352
if (
NativeMethodsShared
.GetShortFilePath(newTmp) == newTmp)
389
if (
NativeMethodsShared
.GetShortFilePath(newTmp) == newTmp)
427
if (
NativeMethodsShared
.GetShortFilePath(newTmp) == newTmp)
464
if (
NativeMethodsShared
.GetShortFilePath(newTmp) == newTmp)
599
if (!
NativeMethodsShared
.IsWindows)
660
if (
NativeMethodsShared
.IsWindows)
683
if (
NativeMethodsShared
.IsWindows)
714
if (
NativeMethodsShared
.IsWindows)
746
var cmdLine =
NativeMethodsShared
.IsWindows
762
var cmdLine =
NativeMethodsShared
.IsWindows
812
var cmdLine =
NativeMethodsShared
.IsWindows
908
exec.Command =
NativeMethodsShared
.IsWindows ? "echo [%MYENVVAR%]" : "echo [$myenvvar]";
1061
Exec exec = PrepareExec(
NativeMethodsShared
.IsWindows ? $"type {textFilePath}" : $"cat {textFilePath}");
FindUnderPath_Tests.cs (3)
106
new TaskItem(
NativeMethodsShared
.IsWindows ? @"C:\SomeoneElsesProject\File2.txt" : "/SomeoneElsesProject/File2.txt") };
140
Assert.Equal(
NativeMethodsShared
.IsWindows ? @"C:\SomeoneElsesProject\File2.txt" : "/SomeoneElsesProject/File2.txt",
163
Assert.Equal(
NativeMethodsShared
.IsWindows ? @"C:\SomeoneElsesProject\File2.txt" : "/SomeoneElsesProject/File2.txt",
GetReferencePaths_Tests.cs (1)
278
if (
NativeMethodsShared
.IsWindows)
MakeDir_Tests.cs (2)
92
if (
NativeMethodsShared
.IsWindows)
116
if (!
NativeMethodsShared
.IsWindows)
NativeMethodsShared_Tests.cs (11)
38
IntPtr kernel32Dll =
NativeMethodsShared
.LoadLibrary("kernel32.dll");
41
IntPtr processHandle =
NativeMethodsShared
.NullIntPtr;
42
if (kernel32Dll !=
NativeMethodsShared
.NullIntPtr)
44
processHandle =
NativeMethodsShared
.GetProcAddress(kernel32Dll, "GetCurrentProcessId");
52
Assert.NotEqual(processHandle,
NativeMethodsShared
.NullIntPtr);
63
if (kernel32Dll !=
NativeMethodsShared
.NullIntPtr)
65
NativeMethodsShared
.FreeLibrary(kernel32Dll);
79
DateTime nonexistentFileTime =
NativeMethodsShared
.GetLastWriteFileUtcTime(nonexistentFile);
92
DateTime directoryTime =
NativeMethodsShared
.GetLastWriteFileUtcTime(directory);
106
Assert.False(
NativeMethodsShared
.GetLastWriteDirectoryUtcTime(file, out directoryTime));
141
NativeMethodsShared
.SetCurrentDirectory(nonexistentDirectory);
ReadLinesFromFile_Tests.cs (1)
225
if (
NativeMethodsShared
.IsUnixLike)
ResolveSDKReference_Tests.cs (2)
25
private readonly string _sdkPath =
NativeMethodsShared
.IsWindows
1519
string goodSDKLocation =
NativeMethodsShared
.IsWindows ? "C:\\GoodSDKLocation\\" : "/GoodSDKLocation/";
ResourceHandling\GenerateResource_Tests.cs (8)
430
NativeMethodsShared
.IsWindows ? bitmap.ToUpper() : bitmap,
698
NativeMethodsShared
.IsWindows ? bitmap.ToUpper() : bitmap);
744
if (!
NativeMethodsShared
.IsWindows)
954
if (!
NativeMethodsShared
.IsWindows)
3107
t.StronglyTypedFileName =
NativeMethodsShared
.IsWindows ? "||" : "\0";
3967
System.Threading.Thread.Sleep(
NativeMethodsShared
.IsOSX ? 1000 : 100);
4364
NativeMethodsShared
.IsWindows
4454
NativeMethodsShared
.IsWindows ? smallestBitmapFile.ToUpperInvariant() : smallestBitmapFile,
ResourceHandling\GenerateResourceOutOfProc_Tests.cs (1)
2538
t.OutputResources = new ITaskItem[] { new TaskItem(
NativeMethodsShared
.IsWindows ? "||" : "\0") };
SdkToolsPathUtility_Tests.cs (1)
17
private string _defaultSdkToolsPath =
NativeMethodsShared
.IsWindows ? "C:\\ProgramFiles\\WIndowsSDK\\bin" : "/ProgramFiles/WindowsSDK/bin";
SGen_Tests.cs (3)
182
sgen.BuildAssemblyPath =
NativeMethodsShared
.IsUnixLike
200
sgen.BuildAssemblyPath =
NativeMethodsShared
.IsUnixLike
217
sgen.BuildAssemblyPath =
NativeMethodsShared
.IsUnixLike ? "/SomeFolder/MyAsm.dll" : "C:\\SomeFolder\\MyAsm.dll";
Touch_Tests.cs (4)
26
internal static string myexisting_txt =
NativeMethodsShared
.IsWindows ? @"c:\touch\myexisting.txt" : @"/touch/myexisting.txt";
27
internal static string mynonexisting_txt =
NativeMethodsShared
.IsWindows ? @"c:\touch\mynonexisting.txt" : @"/touch/mynonexisting.txt";
28
internal static string nonexisting_txt =
NativeMethodsShared
.IsWindows ? @"c:\touch-nonexistent\file.txt" : @"/touch-nonexistent/file.txt";
29
internal static string myreadonly_txt =
NativeMethodsShared
.IsWindows ? @"c:\touch\myreadonly.txt" : @"/touch/myreadonly.txt";
Unzip_Tests.cs (1)
161
if (
NativeMethodsShared
.IsWindows)
WriteCodeFragment_Tests.cs (1)
610
public static string EscapedLineSeparator =>
NativeMethodsShared
.IsWindows ? "\\r\\n" : "\\n";
XamlDataDrivenToolTask_Tests.cs (1)
411
var cmdLine =
NativeMethodsShared
.IsWindows
Microsoft.Build.UnitTests.Shared (14)
BootstrapLocationAttribute.cs (1)
4
global using NativeMethodsShared = Microsoft.Build.Framework.
NativeMethods
;
DriveMapping.cs (3)
29
NativeMethodsShared
.ThrowExceptionForErrorCode(Marshal.GetLastWin32Error());
42
NativeMethodsShared
.ThrowExceptionForErrorCode(Marshal.GetLastWin32Error());
68
NativeMethodsShared
.ThrowExceptionForErrorCode(err);
DummyMappedDrive.cs (2)
24
if (!
NativeMethodsShared
.IsWindows)
60
if (_mapped &&
NativeMethodsShared
.IsWindows)
DummyMappedDriveUtils.cs (1)
25
return
NativeMethods
.IsWindows ? new DummyMappedDrive() : default;
LongPathSupportDisabledFactAttribute.cs (1)
35
if (!
NativeMethodsShared
.IsMaxPathLegacyWindows())
ObjectModelHelpers.cs (2)
2009
NativeMethodsShared
.IsWindows
2020
NativeMethodsShared
.IsWindows
RequiresSymbolicLinksFactAttribute.cs (2)
22
if (s_runningInAzurePipeline || !
NativeMethodsShared
.IsWindows)
36
if (!
NativeMethodsShared
.MakeSymbolicLink(destinationFile, sourceFile, ref errorMessage))
RunnerUtilities.cs (1)
100
if (
NativeMethodsShared
.IsWindows)
TestEnvironment.cs (1)
655
if (
NativeMethodsShared
.IsUnixLike)
Microsoft.Build.Utilities.Core (30)
AssemblyFoldersEx.cs (1)
80
if (!
NativeMethodsShared
.IsWindows)
AssemblyInfo.cs (1)
4
global using NativeMethodsShared = Microsoft.Build.Framework.
NativeMethods
;
LockCheck.cs (1)
259
if (
NativeMethodsShared
.IsWindows)
ProcessorArchitecture.cs (11)
84
string architecture =
NativeMethodsShared
.ProcessorArchitecture switch
86
NativeMethodsShared
.ProcessorArchitectures.X86 => X86,
87
NativeMethodsShared
.ProcessorArchitectures.X64 => AMD64,
88
NativeMethodsShared
.ProcessorArchitectures.IA64 => IA64,
89
NativeMethodsShared
.ProcessorArchitectures.ARM => ARM,
90
NativeMethodsShared
.ProcessorArchitectures.ARM64 => ARM64,
91
NativeMethodsShared
.ProcessorArchitectures.WASM => WASM,
92
NativeMethodsShared
.ProcessorArchitectures.S390X => S390X,
93
NativeMethodsShared
.ProcessorArchitectures.LOONGARCH64 => LOONGARCH64,
94
NativeMethodsShared
.ProcessorArchitectures.ARMV6 => ARMV6,
95
NativeMethodsShared
.ProcessorArchitectures.PPC64LE => PPC64LE,
ToolLocationHelper.cs (11)
1826
if (
NativeMethodsShared
.IsWindows && platformTarget != null)
2444
string registryRoot =
NativeMethodsShared
.IsWindows ? GetTargetPlatformMonikerRegistryRoots(registrySearchLocation) : string.Empty;
2469
if (
NativeMethodsShared
.IsWindows)
2895
if (
NativeMethodsShared
.IsWindows)
2917
diskRoots.Add(
NativeMethodsShared
.FrameworkBasePath);
3392
return
NativeMethodsShared
.ProcessorArchitectureNative switch
3394
NativeMethodsShared
.ProcessorArchitectures.X64 => ProcessorArchitecture.AMD64,
3395
NativeMethodsShared
.ProcessorArchitectures.IA64 => ProcessorArchitecture.IA64,
3396
NativeMethodsShared
.ProcessorArchitectures.ARM64 => ProcessorArchitecture.ARM64,
3399
NativeMethodsShared
.ProcessorArchitectures.X86 => null,
3400
NativeMethodsShared
.ProcessorArchitectures.ARM => null,
ToolTask.cs (5)
673
if (
NativeMethodsShared
.IsWindows)
808
if (
NativeMethodsShared
.IsWindows)
1507
bool runningOnWindows =
NativeMethodsShared
.IsWindows;
1572
batchFileForCommandLine =
NativeMethodsShared
.GetShortFilePath(batchFileForCommandLine);
1740
if (
NativeMethodsShared
.IsWindows)
Microsoft.Build.Utilities.UnitTests (99)
AssemblyInfo.cs (1)
4
global using NativeMethodsShared = Microsoft.Build.Framework.
NativeMethods
;
NativeMethodsShared_Tests.cs (11)
38
IntPtr kernel32Dll =
NativeMethodsShared
.LoadLibrary("kernel32.dll");
41
IntPtr processHandle =
NativeMethodsShared
.NullIntPtr;
42
if (kernel32Dll !=
NativeMethodsShared
.NullIntPtr)
44
processHandle =
NativeMethodsShared
.GetProcAddress(kernel32Dll, "GetCurrentProcessId");
52
Assert.NotEqual(processHandle,
NativeMethodsShared
.NullIntPtr);
63
if (kernel32Dll !=
NativeMethodsShared
.NullIntPtr)
65
NativeMethodsShared
.FreeLibrary(kernel32Dll);
79
DateTime nonexistentFileTime =
NativeMethodsShared
.GetLastWriteFileUtcTime(nonexistentFile);
92
DateTime directoryTime =
NativeMethodsShared
.GetLastWriteFileUtcTime(directory);
106
Assert.False(
NativeMethodsShared
.GetLastWriteDirectoryUtcTime(file, out directoryTime));
141
NativeMethodsShared
.SetCurrentDirectory(nonexistentDirectory);
ProcessExtensions_Tests.cs (4)
25
var psi =
NativeMethodsShared
.IsWindows
36
NativeMethodsShared
.IsWindows ?
64
if (
NativeMethodsShared
.IsWindows)
94
if (
NativeMethodsShared
.IsWindows)
ProcessorArchitecture_Tests.cs (11)
17
return
NativeMethodsShared
.ProcessorArchitecture switch
19
NativeMethodsShared
.ProcessorArchitectures.X86 => ProcessorArchitecture.X86,
20
NativeMethodsShared
.ProcessorArchitectures.X64 => ProcessorArchitecture.AMD64,
21
NativeMethodsShared
.ProcessorArchitectures.IA64 => ProcessorArchitecture.IA64,
22
NativeMethodsShared
.ProcessorArchitectures.ARM => ProcessorArchitecture.ARM,
23
NativeMethodsShared
.ProcessorArchitectures.ARM64 => ProcessorArchitecture.ARM64,
24
NativeMethodsShared
.ProcessorArchitectures.WASM => ProcessorArchitecture.WASM,
25
NativeMethodsShared
.ProcessorArchitectures.S390X => ProcessorArchitecture.S390X,
26
NativeMethodsShared
.ProcessorArchitectures.LOONGARCH64 => ProcessorArchitecture.LOONGARCH64,
27
NativeMethodsShared
.ProcessorArchitectures.ARMV6 => ProcessorArchitecture.ARMV6,
28
NativeMethodsShared
.ProcessorArchitectures.PPC64LE => ProcessorArchitecture.PPC64LE,
TaskItem_Tests.cs (2)
226
from.ItemSpec =
NativeMethodsShared
.IsWindows ? @"c:\subdir\Monkey.txt" : "/subdir/Monkey.txt";
227
from.GetMetadata(ItemSpecModifiers.Directory).ShouldBe(
NativeMethodsShared
.IsWindows ? @"subdir\" : "subdir/");
ToolLocationHelper_Tests.cs (11)
372
NativeMethodsShared
.IsWindows ? "f:\\IDontExistAtAll" : "/IDontExistAtAll");
384
NativeMethodsShared
.IsWindows ? "f:\\IDontExistAtAll" : "/IDontExistAtAll",
1260
string targetFrameworkRootPath =
NativeMethodsShared
.IsWindows
1281
string targetFrameworkRootPath =
NativeMethodsShared
.IsWindows
1303
string targetFrameworkRootPath =
NativeMethodsShared
.IsWindows
1324
string targetFrameworkRootPath =
NativeMethodsShared
.IsWindows
1347
string targetFrameworkRootPath =
NativeMethodsShared
.IsWindows
3068
string tooLongPath =
NativeMethodsShared
.IsWindows
3103
string normalDirectory =
NativeMethodsShared
.IsWindows ? "c:\\SDKPath" : "/SDKPath";
3124
string frameworkPathPattern =
NativeMethodsShared
.IsWindows ? @"Microsoft SDKs\Windows\v8.0\ExtensionSDKs\MyFramework" : "Microsoft SDKs/Windows/v8.0/ExtensionSDKs/MyFramework";
3125
string frameworkPathPattern2 =
NativeMethodsShared
.IsWindows ? @"ExtensionSDKs\MyFramework" : "ExtensionSDKs/MyFramework";
ToolTask_Tests.cs (59)
43
NativeMethodsShared
.IsUnixLike ? "/bin" : Environment.GetFolderPath(Environment.SpecialFolder.System),
44
NativeMethodsShared
.IsUnixLike ? "sh" : "cmd.exe");
114
if (!
NativeMethodsShared
.IsWindows && string.IsNullOrEmpty(responseFileCommands) && string.IsNullOrEmpty(commandLineCommands))
121
StartInfo = GetProcessStartInfo(GenerateFullPathToTool(),
NativeMethodsShared
.IsWindows ? "/x" : string.Empty, null);
133
t.ToolPath =
NativeMethodsShared
.IsWindows ? @"C:\MyAlternatePath" : "/MyAlternatePath";
149
t.ToolPath =
NativeMethodsShared
.IsWindows ? @"C:\MyAlternatePath" : "/MyAlternatePath";
168
string systemPath =
NativeMethodsShared
.IsUnixLike ? "/bin" : Environment.GetFolderPath(Environment.SpecialFolder.System);
169
t.FullToolName = Path.Combine(systemPath,
NativeMethodsShared
.IsWindows ? "attrib.exe" : "ps");
191
t.MockCommandLineCommands =
NativeMethodsShared
.IsWindows ? "/C garbagegarbagegarbagegarbage.exe" : "-c garbagegarbagegarbagegarbage.exe";
194
t.ExitCode.ShouldBe(
NativeMethodsShared
.IsWindows ? 1 : 127); // cmd.exe error code is 1, sh error code is 127
216
t.MockCommandLineCommands =
NativeMethodsShared
.IsWindows
243
t.MockCommandLineCommands =
NativeMethodsShared
.IsWindows
275
string singleQuote =
NativeMethodsShared
.IsWindows ? "'" : string.Empty;
292
t.MockCommandLineCommands =
NativeMethodsShared
.IsWindows
316
t.MockCommandLineCommands =
NativeMethodsShared
.IsWindows
343
t.MockCommandLineCommands =
NativeMethodsShared
.IsWindows
373
t.MockCommandLineCommands =
NativeMethodsShared
.IsWindows
402
t.FullToolName =
NativeMethodsShared
.IsWindows ? "c:\\baz\\foo.exe" : "/baz/foo.exe";
417
string shellName =
NativeMethodsShared
.IsWindows ? "cmd.exe" : "sh";
418
string copyName =
NativeMethodsShared
.IsWindows ? "xcopy.exe" : "cp";
424
string systemPath =
NativeMethodsShared
.IsUnixLike ? "/bin" : Environment.GetFolderPath(Environment.SpecialFolder.System);
470
string toolName =
NativeMethodsShared
.IsWindows ? "cmd.exe" : "sh";
477
string systemPath =
NativeMethodsShared
.IsUnixLike ? "/bin" : Environment.GetFolderPath(Environment.SpecialFolder.System);
498
t.FullToolName =
NativeMethodsShared
.IsWindows ? "findstr.exe" : "grep";
526
t.FullToolName =
NativeMethodsShared
.IsWindows ? "findstr.exe" : "grep";
548
string toolName =
NativeMethodsShared
.IsWindows ? "cmd.exe" : "sh";
587
t.MockCommandLineCommands =
NativeMethodsShared
.IsWindows
614
string userVarName =
NativeMethodsShared
.IsWindows ? "username" : "user";
628
if (
NativeMethodsShared
.IsWindows)
720
string toolName =
NativeMethodsShared
.IsWindows ? "cmd" : "sh";
762
if (
NativeMethodsShared
.IsWindows)
801
t.MockCommandLineCommands =
NativeMethodsShared
.IsWindows
834
t.MockCommandLineCommands =
NativeMethodsShared
.IsWindows
931
if (
NativeMethodsShared
.IsUnixLike // treat all UNIXy OSes as capable of UTF-8 everywhere
1071
t.MockCommandLineCommands =
NativeMethodsShared
.IsWindows
1103
t.MockCommandLineCommands =
NativeMethodsShared
.IsWindows ?
1134
_pathToTool =
NativeMethodsShared
.IsUnixLike
1178
return
NativeMethodsShared
.IsUnixLike
1297
string projectDir =
NativeMethodsShared
.IsUnixLike ? "/tmp" : @"C:\SomeProjectDir";
1301
string toolPath =
NativeMethodsShared
.IsUnixLike ? "/bin/sh" : @"C:\Windows\System32\cmd.exe";
1317
string projectDir =
NativeMethodsShared
.IsUnixLike ? "/tmp" : @"C:\SomeProjectDir";
1325
string toolPath =
NativeMethodsShared
.IsUnixLike ? "/bin/sh" : @"C:\Windows\System32\cmd.exe";
1341
string projectDir =
NativeMethodsShared
.IsUnixLike ? "/projects/myapp" : @"C:\Projects\MyApp";
1345
string toolPath =
NativeMethodsShared
.IsUnixLike ? "/bin/sh" : @"C:\Windows\System32\cmd.exe";
1362
string projectDir =
NativeMethodsShared
.IsUnixLike ? "/projects/myapp" : @"C:\Projects\MyApp";
1363
string overrideDir =
NativeMethodsShared
.IsUnixLike ? "/custom/workdir" : @"D:\Custom\WorkDir";
1367
string toolPath =
NativeMethodsShared
.IsUnixLike ? "/bin/sh" : @"C:\Windows\System32\cmd.exe";
1383
string expectedWorkingDir =
NativeMethodsShared
.IsUnixLike ? "/tmp" : @"C:\SomeProjectDir";
1392
string toolPath =
NativeMethodsShared
.IsUnixLike ? "/bin/sh" : @"C:\Windows\System32\cmd.exe";
1415
string toolPath =
NativeMethodsShared
.IsUnixLike ? "/bin/sh" : @"C:\Windows\System32\cmd.exe";
1436
string projectDir =
NativeMethodsShared
.IsUnixLike ? "/tmp" : @"C:\SomeProjectDir";
1440
string toolPath =
NativeMethodsShared
.IsUnixLike ? "/bin/sh" : @"C:\Windows\System32\cmd.exe";
1458
string toolName =
NativeMethodsShared
.IsWindows ? "mytesttool.exe" : "mytesttool";
1469
string fullToolName =
NativeMethodsShared
.IsUnixLike ? "/bin/sh" : @"C:\Windows\System32\cmd.exe";
1495
string toolPath =
NativeMethodsShared
.IsUnixLike ? "/bin/sh" : @"C:\Windows\System32\cmd.exe";
1514
string projectDir =
NativeMethodsShared
.IsUnixLike ? "/tmp" : @"C:\SomeProjectDir";
1518
string toolPath =
NativeMethodsShared
.IsUnixLike ? "/bin/sh" : @"C:\Windows\System32\cmd.exe";
1541
string toolPath =
NativeMethodsShared
.IsUnixLike ? "/bin/sh" : @"C:\Windows\System32\cmd.exe";
1561
string toolName =
NativeMethodsShared
.IsWindows ? "mytool.exe" : "mytool";
MSBuild (20)
AssemblyInfo.cs (1)
4
global using NativeMethodsShared = Microsoft.Build.Framework.
NativeMethods
;
CommandLine\CommandLineParser.cs (1)
287
int numberOfCpus =
NativeMethodsShared
.GetLogicalCoreCount();
CommunicationsUtilities.cs (2)
287
if (includeSessionId &&
NativeMethodsShared
.IsWindows)
583
if (!
NativeMethodsShared
.IsWindows)
NamedPipeUtil.cs (1)
26
if (
NativeMethodsShared
.IsUnixLike)
OutOfProcTaskHostNode.cs (2)
983
NativeMethodsShared
.SetCurrentDirectory(BuildEnvironmentHelper.Instance.CurrentMSBuildToolsDirectory);
1070
NativeMethodsShared
.SetCurrentDirectory(taskConfiguration.StartupDirectory);
XMake.cs (13)
1081
NativeMethodsShared
.RestoreConsoleMode(s_originalConsoleMode);
1115
NativeMethodsShared
.FrameworkName,
1803
NativeMethodsShared
.LongPathsStatus longPaths =
NativeMethodsShared
.IsLongPathsEnabled();
1804
if (longPaths !=
NativeMethodsShared
.LongPathsStatus.NotApplicable)
1815
NativeMethodsShared
.SAC_State SAC_State =
NativeMethodsShared
.GetSACState();
1816
if (SAC_State !=
NativeMethodsShared
.SAC_State.NotApplicable && SAC_State !=
NativeMethodsShared
.SAC_State.Missing)
1921
if (
NativeMethodsShared
.IsWindows &&
2405
(var acceptAnsiColorCodes, var outputIsScreen, s_originalConsoleMode) =
NativeMethodsShared
.QueryIsScreenAndTryEnableAnsiColorCodes();
2558
(_, _, s_originalConsoleMode) =
NativeMethodsShared
.QueryIsScreenAndTryEnableAnsiColorCodes();
4175
Console.WriteLine(ResourceUtilities.FormatResourceStringStripCodeAndKeyword("MSBuildVersionMessage", ProjectCollection.DisplayVersion,
NativeMethods
.FrameworkName));