239 references to NativeMethods
Microsoft.Build (65)
AssemblyInfo.cs (1)
4global using NativeMethodsShared = Microsoft.Build.Framework.NativeMethods;
BackEnd\BuildManager\BuildManager.cs (7)
506if (NativeMethodsShared.IsWindows || parameters.LowPriority) 1145_buildTelemetry.BuildEngineFrameworkName = NativeMethodsShared.FrameworkName; 1159var sacState = NativeMethodsShared.GetSACState(); 1161_buildTelemetry.SACEnabled = sacState == NativeMethodsShared.SAC_State.Evaluation || sacState == NativeMethodsShared.SAC_State.Enforcement; 1251NativeMethodsShared.FrameworkName, 1273BuildEngineFrameworkName = NativeMethodsShared.FrameworkName,
BackEnd\BuildManager\BuildParameters.cs (1)
65private static string s_startupDirectory = NativeMethodsShared.GetCurrentDirectory();
BackEnd\Client\MSBuildClient.cs (2)
244NativeMethodsShared.RestoreConsoleMode(_originalConsoleMode); 388(var acceptAnsiColorCodes, var outputIsScreen, _originalConsoleMode) = NativeMethodsShared.QueryIsScreenAndTryEnableAnsiColorCodes();
BackEnd\Components\Caching\ResultsCache.cs (1)
248capacity => new ConcurrentDictionary<int, BuildResult>(NativeMethodsShared.GetLogicalCoreCount(), capacity));
BackEnd\Components\Communications\NodeLauncher.cs (1)
77return NativeMethodsShared.IsUnixLike
BackEnd\Components\Communications\NodeProviderOutOfProcBase.cs (1)
703return Math.Max(1, (3 * NativeMethodsShared.GetLogicalCoreCount()) / 2);
BackEnd\Components\Communications\RarNodeLauncher.cs (1)
56if (NativeMethodsShared.IsWindows)
BackEnd\Components\RequestBuilder\TargetUpToDateChecker.cs (5)
985oldestOutputFileTime = NativeMethodsShared.GetLastWriteFileUtcTime(oldestOutputFullPath); 1010candidateOutputFileTime = NativeMethodsShared.GetLastWriteFileUtcTime(candidateOutputFullPath); 1045inputFileTime = NativeMethodsShared.GetLastWriteFileUtcTime(unescapedInputFullPath); 1200var path1WriteTime = NativeMethodsShared.GetLastWriteFileUtcTime(path1); 1203var path2WriteTime = NativeMethodsShared.GetLastWriteFileUtcTime(path2);
BackEnd\Components\Scheduler\Scheduler.cs (1)
255_coreLimit = NativeMethodsShared.GetLogicalCoreCount();
BackEnd\Components\SdkResolution\SdkResolverService.cs (1)
547NativeMethodsShared.GetLogicalCoreCount(),
BackEnd\Node\InProcNode.cs (3)
148_savedCurrentDirectory = NativeMethodsShared.GetCurrentDirectory(); 346NativeMethodsShared.SetCurrentDirectory(_savedCurrentDirectory); 482_savedCurrentDirectory = NativeMethodsShared.GetCurrentDirectory();
BackEnd\Node\OutOfProcNode.cs (4)
495NativeMethodsShared.SetCurrentDirectory(BuildEnvironmentHelper.Instance.CurrentMSBuildToolsDirectory); 722NativeMethodsShared.SetCurrentDirectory(BuildParameters.StartupDirectory); 727NativeMethodsShared.SetCurrentDirectory(BuildEnvironmentHelper.Instance.CurrentMSBuildToolsDirectory); 884if (!lowPriority || NativeMethodsShared.IsWindows)
BackEnd\Node\OutOfProcServerNode.cs (3)
262NativeMethodsShared.SetCurrentDirectory(BuildEnvironmentHelper.Instance.CurrentMSBuildToolsDirectory); 417if (NativeMethodsShared.IsWindows && command.ConsoleConfiguration.BufferWidth > 0) 452NativeMethodsShared.SetCurrentDirectory(BuildEnvironmentHelper.Instance.CurrentMSBuildToolsDirectory);
BackEnd\Shared\BuildRequestConfiguration.cs (2)
473NativeMethodsShared.SetCurrentDirectory(BuildParameters.StartupDirectory); 478NativeMethodsShared.SetCurrentDirectory(
Construction\ProjectRootElement.cs (3)
179_directory = NativeMethodsShared.GetCurrentDirectory(); 204_directory = NativeMethodsShared.GetCurrentDirectory(); 261_directory = NativeMethodsShared.GetCurrentDirectory();
Definition\ToolsetReader.cs (2)
166var libraryPath = NativeMethodsShared.FrameworkBasePath; 490var importSearchPathsTable = GetProjectImportSearchPathsTable(toolsVersion.Name, NativeMethodsShared.GetOSNameForExtensionsPath());
Evaluation\Evaluator.cs (3)
1159if (!NativeMethodsShared.IsWindows) 1161SetBuiltInProperty(ReservedPropertyNames.osName, NativeMethodsShared.OSName); 1162SetBuiltInProperty(ReservedPropertyNames.frameworkToolsRoot, NativeMethodsShared.FrameworkBasePath);
Evaluation\Expander.cs (3)
1746if (!NativeMethodsShared.IsWindows) 1786if (!NativeMethodsShared.IsWindows && !registryKeyName.StartsWith("HKEY_CURRENT_USER", StringComparison.OrdinalIgnoreCase)) 1796return NativeMethodsShared.FrameworkBasePath + Path.DirectorySeparatorChar;
Evaluation\IntrinsicFunctions.cs (8)
206if (!NativeMethodsShared.IsWindows) 222if (!NativeMethodsShared.IsWindows) 235if (!NativeMethodsShared.IsWindows) 257if (!NativeMethodsShared.IsWindows) 288if (!NativeMethodsShared.IsWindows && !keyName.StartsWith("HKEY_CURRENT_USER", StringComparison.OrdinalIgnoreCase)) 297return Path.Combine(NativeMethodsShared.FrameworkBasePath, m.Groups[0].Value) + Path.DirectorySeparatorChar; 588return NativeMethodsShared.IsUnixLike; 597return NativeMethodsShared.IsBSD;
Graph\ProjectGraph.cs (2)
341NativeMethodsShared.GetLogicalCoreCount(), 382NativeMethodsShared.GetLogicalCoreCount(),
Instance\HostServices.cs (1)
89if (NativeMethodsShared.IsWindows)
Logging\BaseConsoleLogger.cs (1)
265runningWithCharacterFileType = NativeMethodsShared.IsWindows && ConsoleConfiguration.OutputIsScreen;
Logging\SimpleErrorLogger.cs (2)
27(acceptAnsiColorCodes, _, originalConsoleMode) = NativeMethods.QueryIsScreenAndTryEnableAnsiColorCodes(useStandardError: true); 88NativeMethods.RestoreConsoleMode(originalConsoleMode, useStandardError: true);
Logging\TerminalLogger\TerminalLogger.cs (5)
271(bool supportsAnsi, bool outputIsScreen, uint? originalConsoleMode) = NativeMethodsShared.QueryIsScreenAndTryEnableAnsiColorCodes(); 283(bool supportsAnsi, bool outputIsScreen, uint? originalConsoleMode) = NativeMethodsShared.QueryIsScreenAndTryEnableAnsiColorCodes(); 373NativeMethodsShared.RestoreConsoleMode(originalConsoleMode); 387NativeMethodsShared.RestoreConsoleMode(originalConsoleMode); 548NativeMethodsShared.RestoreConsoleMode(_originalConsoleMode);
src\msbuild\src\Shared\NamedPipeUtil.cs (1)
26if (NativeMethodsShared.IsUnixLike)
Microsoft.Build.Framework (82)
BackEnd\CommunicationsUtilities.cs (2)
466if (!NativeMethods.IsWindows) 632NativeMethods.IsWindows &&
BackEnd\Handshake.cs (1)
90if (includeSessionId && NativeMethods.IsWindows)
BuildEnvironmentHelper.cs (12)
134if (!NativeMethods.IsWindows) 166if (NativeMethods.IsWindows && 240if (NativeMethods.IsWindows && 370NativeMethods.ProcessorArchitecture == NativeMethods.ProcessorArchitectures.X64 ? "amd64" : 371NativeMethods.ProcessorArchitecture == NativeMethods.ProcessorArchitectures.ARM64 ? "arm64" : string.Empty, 596MSBuildToolsDirectoryRoot = NativeMethods.ProcessorArchitecture switch 598NativeMethods.ProcessorArchitectures.X86 => CurrentMSBuildToolsDirectory, 599NativeMethods.ProcessorArchitectures.X64 or NativeMethods.ProcessorArchitectures.ARM64 602_ => Assumed.Unreachable<string>($"Unknown processor architecture {NativeMethods.ProcessorArchitecture}"),
Constants.cs (2)
31internal static readonly string DotnetProcessName = NativeMethods.IsWindows ? "dotnet.exe" : "dotnet"; 46internal static readonly string MSBuildExecutableName = NativeMethods.IsWindows ? $"{MSBuildAppName}.exe" : MSBuildAppName;
EncodingUtilities.cs (1)
229if (!NativeMethods.IsWindows)
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; 430if (NativeMethods.GetLastWriteDirectoryUtcTime(directoryPath, out lastModifiedTime)) 772if (NativeMethods.IsWindows || string.IsNullOrEmpty(value) 793if (NativeMethods.IsWindows || value.IsEmpty) 874if (NativeMethods.IsWindows) 1002if (NativeMethods.IsWindows && !EndsWithSlash(fullPath)) 1454bool hasMaxPath = NativeMethods.HasMaxPath; 1455int maxPath = NativeMethods.MaxPath; 1457return hasMaxPath && !IsRootedNoThrow(path) && NativeMethods.GetCurrentDirectory().Length + path.Length + 1 /* slash */ >= maxPath;
ItemSpecModifiers.cs (1)
547if (NativeMethods.IsWindows)
MSBuildNameIgnoreCaseComparer.cs (4)
25private static readonly NativeMethods.ProcessorArchitectures s_runningProcessorArchitecture = NativeMethods.ProcessorArchitecture; 117if ((s_runningProcessorArchitecture != NativeMethods.ProcessorArchitectures.IA64) 118&& (s_runningProcessorArchitecture != NativeMethods.ProcessorArchitectures.ARM))
MultiProcessTaskEnvironmentDriver.cs (2)
35get => new AbsolutePath(NativeMethods.GetCurrentDirectory(), ignoreRootedCheck: true); 36set => NativeMethods.SetCurrentDirectory(value.Value);
PathHelpers\AbsolutePath.cs (2)
29private static readonly StringComparer s_pathComparer = NativeMethods.IsFileSystemCaseSensitive ? StringComparer.Ordinal : StringComparer.OrdinalIgnoreCase; 136if (!NativeMethods.IsWindows
Utilities\FileMatcher.cs (5)
1062if (NativeMethods.IsLinux && recursionState.SearchData.DirectoryPattern != null) 1206using (var matchFileExpression = new ReuseableStringBuilder(FileSpecRegexMinLength + NativeMethods.MAX_PATH)) 1259bool isUncPath = NativeMethods.IsWindows && fixedDir.Length > 1 2273if (NativeMethods.IsWindows && 2595var maxTasks = Math.Max(1, NativeMethods.GetLogicalCoreCount() / 2);
Utilities\FrameworkLocationHelper.cs (35)
93internal static string dotNetFrameworkVersionFolderPrefixV11 = NativeMethods.IsWindows ? "v1.1" : "1.1"; // v1.1 is for Everett. 98internal static string dotNetFrameworkVersionFolderPrefixV20 = NativeMethods.IsWindows ? "v2.0" : "2.0"; // v2.0 is for Whidbey. 102internal static string dotNetFrameworkVersionFolderPrefixV30 = NativeMethods.IsWindows ? "v3.0" : "3.0"; // v3.0 is for WinFx. 116internal static string dotNetFrameworkVersionFolderPrefixV35 = NativeMethods.IsWindows ? "v3.5" : "3.5"; // v3.5 is for Orcas. 122internal static string dotNetFrameworkVersionFolderPrefixV40 = NativeMethods.IsWindows ? "v4.0" : "4.0"; 123internal static string dotNetFrameworkVersionFolderPrefixV45 = NativeMethods.IsWindows ? "v4.5" : "4.5"; 444return NativeMethods.IsUnixLike 445? Path.Combine(NativeMethods.FrameworkBasePath, dotNetFrameworkVersionFolderPrefixV11) 454return NativeMethods.IsUnixLike 455? Path.Combine(NativeMethods.FrameworkBasePath, dotNetFrameworkVersionFolderPrefixV20) 464return NativeMethods.IsUnixLike 465? Path.Combine(NativeMethods.FrameworkBasePath, dotNetFrameworkVersionFolderPrefixV30) 474return NativeMethods.IsUnixLike 475? Path.Combine(NativeMethods.FrameworkBasePath, dotNetFrameworkVersionFolderPrefixV35) 484return NativeMethods.IsUnixLike 485? Path.Combine(NativeMethods.FrameworkBasePath, dotNetFrameworkVersionFolderPrefixV40) 494return NativeMethods.IsUnixLike 495? Path.Combine(NativeMethods.FrameworkBasePath, dotNetFrameworkVersionFolderPrefixV45) 504return NativeMethods.IsUnixLike 505? Path.Combine(NativeMethods.FrameworkBasePath, dotNetFrameworkVersionFolderPrefixV11) 514return NativeMethods.IsUnixLike 515? Path.Combine(NativeMethods.FrameworkBasePath, dotNetFrameworkVersionFolderPrefixV20) 538if (!NativeMethods.IsWindows) 540s_fallbackDotNetFrameworkSdkInstallPath = NativeMethods.FrameworkCurrentPath; 588if (NativeMethods.IsWindows) 635if (NativeMethods.IsWindows) 829if (!NativeMethods.IsWindows) 836var frameworkPath = Path.Combine(NativeMethods.FrameworkBasePath, prefix ?? string.Empty); 986combinedPath = NativeMethods.IsWindows 988: Path.Combine(NativeMethods.FrameworkBasePath, "xbuild-frameworks"); 1196dotNetFrameworkVersionFolderPrefix: NativeMethods.IsWindows ? "v4.0" : "v4.5", 1444string currentRuntimePath = NativeMethods.FrameworkCurrentPath; 1496if (NativeMethods.IsUnixLike) 1498string frameworkPath = NativeMethods.FrameworkBasePath; 1587if (NativeMethods.IsWindows)
Utilities\ProcessExtensions.cs (4)
116if (NativeMethods.IsWindows) 122else if (NativeMethods.IsOSX || NativeMethods.IsBSD) 127else if (NativeMethods.IsLinux)
Microsoft.Build.Tasks.Core (43)
AssemblyDependency\AssemblyInformation.cs (1)
308if (!NativeMethodsShared.IsWindows)
AssemblyDependency\AssemblyMetadata.cs (1)
30ScatterFiles = NativeMethodsShared.IsWindows ? import.Files : null;
AssemblyDependency\Reference.cs (1)
514else if (NativeMethodsShared.IsWindows)
AssemblyDependency\ResolveAssemblyReference.cs (1)
3463p => NativeMethodsShared.GetLastWriteFileUtcTime(p),
AssemblyInfo.cs (1)
4global using NativeMethodsShared = Microsoft.Build.Framework.NativeMethods;
Copy.cs (3)
47private static readonly int DefaultCopyParallelism = NativeMethodsShared.GetLogicalCoreCount() > 4 ? 6 : 4; 357TryCopyViaLink(SymbolicLinkComment, MessageImportance.Normal, sourceFileState, destinationFileState, out symbolicLinkCreated, ref errorMessage, (source, destination, errMessage) => NativeMethodsShared.MakeSymbolicLink(destination, source, ref errorMessage)); 360if (!NativeMethodsShared.IsWindows)
Exec.cs (7)
75if (NativeMethodsShared.IsUnixLike) 214if (!NativeMethodsShared.IsUnixLike) 259if (!NativeMethodsShared.IsUnixLike) 525if (NativeMethodsShared.IsWindows) 604if (NativeMethodsShared.IsUnixLike) 619if (NativeMethodsShared.IsWindows) 680protected override string ToolName => NativeMethodsShared.IsWindows ? "cmd.exe" : "sh";
FormatUrl.cs (1)
47if (InputUrl.Length > 0 && NativeMethodsShared.IsWindows && string.IsNullOrWhiteSpace(InputUrl))
GenerateApplicationManifest.cs (1)
116if (!NativeMethodsShared.IsWindows)
GenerateDeploymentManifest.cs (1)
160if (!NativeMethodsShared.IsWindows)
GenerateLauncher.cs (1)
48if (!NativeMethodsShared.IsWindows)
GenerateManifestBase.cs (1)
283if (!NativeMethodsShared.IsWindows)
GenerateResource.cs (7)
1551DateTime outputTime = NativeMethodsShared.GetLastWriteFileUtcTime(outputFilePath); 1561DateTime sourceTime = NativeMethodsShared.GetLastWriteFileUtcTime(sourceFilePath); 1607DateTime linkedFileTime = NativeMethodsShared.GetLastWriteFileUtcTime(linkedFilePath); 1694DateTime sourceTime = NativeMethodsShared.GetLastWriteFileUtcTime(Sources[0].ItemSpec); 1695DateTime outputTime = NativeMethodsShared.GetLastWriteFileUtcTime(StronglyTypedFileName); 1753DateTime time = NativeMethodsShared.GetLastWriteFileUtcTime(input.ItemSpec); 2862if (!NativeMethodsShared.HasMaxPath)
GetInstalledSDKLocations.cs (1)
131if (!NativeMethodsShared.IsWindows)
GetSDKReferenceFiles.cs (1)
230if (!NativeMethodsShared.IsWindows)
ManifestUtil\SecurityUtil.cs (1)
891if (NativeMethodsShared.IsWindows && (toolPath == null || !FileSystems.Default.FileExists(toolPath)))
Move.cs (1)
292if (NativeMethodsShared.IsWindows)
NativeMethods.cs (4)
77if (NativeMethodsShared.IsWindows) 230private static readonly string s_gacPath = Path.Combine(NativeMethodsShared.FrameworkBasePath, "gac"); 274if (NativeMethodsShared.IsWindows) 338if (NativeMethodsShared.IsWindows)
ResolveSDKReference.cs (1)
272if (!NativeMethodsShared.IsWindows)
SignFile.cs (1)
52if (!NativeMethodsShared.IsWindows)
src\msbuild\src\Shared\AssemblyFolders\AssemblyFoldersEx.cs (1)
80if (!NativeMethodsShared.IsWindows)
src\msbuild\src\Shared\NamedPipeUtil.cs (1)
26if (NativeMethodsShared.IsUnixLike)
src\msbuild\src\Shared\NodePipeClient.cs (1)
18private static readonly bool s_useHandhakeTimeout = !NativeMethodsShared.IsWindows;
src\msbuild\src\Shared\NodePipeServer.cs (1)
32private static readonly int s_handshakeTimeout = NativeMethodsShared.IsWindows ? 0 : 60_000;
SystemState.cs (1)
707return lastModified != DateTime.MinValue && lastModified != NativeMethodsShared.MinFileDate;
Unzip.cs (1)
269if (mode != UnixFileMode.None && NativeMethodsShared.IsUnixLike)
Microsoft.Build.Utilities.Core (29)
AssemblyInfo.cs (1)
4global using NativeMethodsShared = Microsoft.Build.Framework.NativeMethods;
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,
src\msbuild\src\Shared\AssemblyFolders\AssemblyFoldersEx.cs (1)
80if (!NativeMethodsShared.IsWindows)
ToolLocationHelper.cs (11)
1826if (NativeMethodsShared.IsWindows && platformTarget != null) 2444string registryRoot = NativeMethodsShared.IsWindows ? GetTargetPlatformMonikerRegistryRoots(registrySearchLocation) : string.Empty; 2469if (NativeMethodsShared.IsWindows) 2895if (NativeMethodsShared.IsWindows) 2917diskRoots.Add(NativeMethodsShared.FrameworkBasePath); 3387=> NativeMethodsShared.ProcessorArchitectureNative switch 3389NativeMethodsShared.ProcessorArchitectures.X64 => ProcessorArchitecture.AMD64, 3390NativeMethodsShared.ProcessorArchitectures.IA64 => ProcessorArchitecture.IA64, 3391NativeMethodsShared.ProcessorArchitectures.ARM64 => ProcessorArchitecture.ARM64, 3395NativeMethodsShared.ProcessorArchitectures.X86 => null, 3396NativeMethodsShared.ProcessorArchitectures.ARM => null,
ToolTask.cs (5)
673if (NativeMethodsShared.IsWindows) 808if (NativeMethodsShared.IsWindows) 1508bool runningOnWindows = NativeMethodsShared.IsWindows; 1573batchFileForCommandLine = NativeMethodsShared.GetShortFilePath(batchFileForCommandLine); 1740if (NativeMethodsShared.IsWindows)
MSBuild (20)
AssemblyInfo.cs (1)
4global using NativeMethodsShared = Microsoft.Build.Framework.NativeMethods;
CommandLine\CommandLineParser.cs (1)
287int numberOfCpus = NativeMethodsShared.GetLogicalCoreCount();
OutOfProcTaskHostNode.cs (4)
1126context.SavedCurrentDirectory = NativeMethodsShared.GetCurrentDirectory(); 1150NativeMethodsShared.SetCurrentDirectory(context.SavedCurrentDirectory); 1299NativeMethodsShared.SetCurrentDirectory(BuildEnvironmentHelper.Instance.CurrentMSBuildToolsDirectory); 1422NativeMethodsShared.SetCurrentDirectory(taskConfiguration.StartupDirectory);
src\msbuild\src\Shared\NamedPipeUtil.cs (1)
26if (NativeMethodsShared.IsUnixLike)
XMake.cs (13)
1092NativeMethodsShared.RestoreConsoleMode(s_originalConsoleMode); 1126NativeMethodsShared.FrameworkName, 1814NativeMethodsShared.LongPathsStatus longPaths = NativeMethodsShared.IsLongPathsEnabled(); 1815if (longPaths != NativeMethodsShared.LongPathsStatus.NotApplicable) 1826NativeMethodsShared.SAC_State SAC_State = NativeMethodsShared.GetSACState(); 1827if (SAC_State != NativeMethodsShared.SAC_State.NotApplicable && SAC_State != NativeMethodsShared.SAC_State.Missing) 1932if (NativeMethodsShared.IsWindows && 2423(var acceptAnsiColorCodes, var outputIsScreen, s_originalConsoleMode) = NativeMethodsShared.QueryIsScreenAndTryEnableAnsiColorCodes(); 2576(_, _, s_originalConsoleMode) = NativeMethodsShared.QueryIsScreenAndTryEnableAnsiColorCodes(); 4202Console.WriteLine(ResourceUtilities.FormatResourceStringStripCodeAndKeyword("MSBuildVersionMessage", ProjectCollection.DisplayVersion, NativeMethods.FrameworkName));