248 references to NativeMethods
Microsoft.Build (64)
AssemblyInfo.cs (1)
4global using NativeMethodsShared = Microsoft.Build.Framework.NativeMethods;
BackEnd\BuildManager\BuildManager.cs (7)
566if (NativeMethodsShared.IsWindows || parameters.LowPriority) 1379_buildTelemetry.BuildEngineFrameworkName = NativeMethodsShared.FrameworkName; 1398var sacState = NativeMethodsShared.GetSACState(); 1400_buildTelemetry.SACEnabled = sacState == NativeMethodsShared.SAC_State.Evaluation || sacState == NativeMethodsShared.SAC_State.Enforcement; 1513NativeMethodsShared.FrameworkName, 1535BuildEngineFrameworkName = NativeMethodsShared.FrameworkName,
BackEnd\BuildManager\MultiThreadedStrictModeScope.cs (6)
82sentinelDirectory = NativeMethodsShared.IsWindows 83? NativeMethodsShared.GetLongFilePath(sentinelDirectory) 84: NativeMethodsShared.RealPath(sentinelDirectory) ?? throw new Win32Exception(); 85string canonicalTemporaryDirectory = NativeMethodsShared.IsWindows 86? NativeMethodsShared.GetLongFilePath(temporaryDirectory) 87: NativeMethodsShared.RealPath(temporaryDirectory) ?? throw new Win32Exception();
BackEnd\Client\MSBuildClient.cs (2)
289NativeMethodsShared.RestoreConsoleMode(_originalConsoleMode); 457(var acceptAnsiColorCodes, var outputIsScreen, _originalConsoleMode) = NativeMethodsShared.QueryIsScreenAndTryEnableAnsiColorCodes();
BackEnd\Components\Caching\ResultsCache.cs (1)
269capacity => new ConcurrentDictionary<int, BuildResult>(NativeMethodsShared.GetLogicalCoreCount(), capacity));
BackEnd\Components\Communications\NodeLauncher.cs (1)
77return NativeMethodsShared.IsUnixLike
BackEnd\Components\Communications\NodeProviderOutOfProcBase.cs (1)
776return Math.Max(1, (3 * NativeMethodsShared.GetLogicalCoreCount()) / 2);
BackEnd\Components\Communications\RarNodeLauncher.cs (1)
56if (NativeMethodsShared.IsWindows)
BackEnd\Components\RequestBuilder\TargetUpToDateChecker.cs (5)
994oldestOutputFileTime = NativeMethodsShared.GetLastWriteFileUtcTime(oldestOutputFullPath); 1019candidateOutputFileTime = NativeMethodsShared.GetLastWriteFileUtcTime(candidateOutputFullPath); 1054inputFileTime = NativeMethodsShared.GetLastWriteFileUtcTime(unescapedInputFullPath); 1209var path1WriteTime = NativeMethodsShared.GetLastWriteFileUtcTime(path1); 1212var path2WriteTime = NativeMethodsShared.GetLastWriteFileUtcTime(path2);
BackEnd\Components\Scheduler\Scheduler.cs (1)
257_coreLimit = NativeMethodsShared.GetLogicalCoreCount();
BackEnd\Components\SdkResolution\SdkResolverService.cs (1)
557NativeMethodsShared.GetLogicalCoreCount(),
BackEnd\Node\InProcNode.cs (1)
349NativeMethodsShared.SetCurrentDirectory(_savedCurrentDirectory);
BackEnd\Node\OutOfProcNode.cs (4)
510NativeMethodsShared.SetCurrentDirectory(BuildEnvironmentHelper.Instance.CurrentMSBuildToolsDirectory); 744NativeMethodsShared.SetCurrentDirectory(BuildParameters.StartupDirectory); 749NativeMethodsShared.SetCurrentDirectory(BuildEnvironmentHelper.Instance.CurrentMSBuildToolsDirectory); 906if (!lowPriority || NativeMethodsShared.IsWindows)
BackEnd\Node\OutOfProcServerNode.cs (5)
292NativeMethodsShared.SetCurrentDirectory(BuildEnvironmentHelper.Instance.CurrentMSBuildToolsDirectory); 437NativeMethodsShared.ConsoleConfigurationOverride = 464if (NativeMethodsShared.IsWindows && command.ConsoleConfiguration.BufferWidth > 0) 498NativeMethodsShared.ConsoleConfigurationOverride = null; 503NativeMethodsShared.SetCurrentDirectory(BuildEnvironmentHelper.Instance.CurrentMSBuildToolsDirectory);
BackEnd\Shared\BuildRequestConfiguration.cs (2)
540NativeMethodsShared.SetCurrentDirectory(BuildParameters.StartupDirectory); 545NativeMethodsShared.SetCurrentDirectory(
Definition\ToolsetReader.cs (2)
182var libraryPath = NativeMethodsShared.FrameworkBasePath; 506var importSearchPathsTable = GetProjectImportSearchPathsTable(toolsVersion.Name, NativeMethodsShared.GetOSNameForExtensionsPath());
Evaluation\Evaluator.cs (3)
1307if (!NativeMethodsShared.IsWindows) 1309SetBuiltInProperty(ReservedPropertyNames.OSName, NativeMethodsShared.OSName); 1310SetBuiltInProperty(ReservedPropertyNames.FrameworkToolsRoot, NativeMethodsShared.FrameworkBasePath);
Evaluation\Expander.PropertyExpander.cs (1)
691if (!NativeMethodsShared.IsWindows)
Evaluation\IntrinsicFunctions.cs (7)
205if (!NativeMethodsShared.IsWindows) 221if (!NativeMethodsShared.IsWindows) 234if (!NativeMethodsShared.IsWindows) 256if (!NativeMethodsShared.IsWindows) 287if (!NativeMethodsShared.IsWindows && !keyName.StartsWith("HKEY_CURRENT_USER", StringComparison.OrdinalIgnoreCase)) 296return Path.Combine(NativeMethodsShared.FrameworkBasePath, m.Groups[0].Value) + Path.DirectorySeparatorChar; 613return NativeMethodsShared.IsUnixLike;
Graph\ProjectGraph.cs (2)
342NativeMethodsShared.GetLogicalCoreCount(), 383NativeMethodsShared.GetLogicalCoreCount(),
Graph\ProjectGraphOptions.cs (1)
33public int DegreeOfParallelism { get; init; } = NativeMethodsShared.GetLogicalCoreCount();
Instance\HostServices.cs (1)
90if (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);
Microsoft.Build.Framework (112)
BackEnd\CommunicationsUtilities.cs (2)
497if (!NativeMethods.IsWindows) 675NativeMethods.IsWindows &&
BackEnd\Handshake.cs (2)
120if (includeSessionId && NativeMethods.IsWindows) 192if (!NativeMethods.IsWindows || string.IsNullOrEmpty(path) || path!.Length < 2 || path[1] != ':')
BackEnd\NamedPipeUtil.cs (1)
23if (NativeMethods.IsUnixLike)
BuildEnvironmentHelper.cs (12)
171if (!NativeMethods.IsWindows) 203if (NativeMethods.IsWindows && 277if (NativeMethods.IsWindows && 407NativeMethods.ProcessorArchitecture == NativeMethods.ProcessorArchitectures.X64 ? "amd64" : 408NativeMethods.ProcessorArchitecture == NativeMethods.ProcessorArchitectures.ARM64 ? "arm64" : string.Empty, 623MSBuildToolsDirectoryRoot = NativeMethods.ProcessorArchitecture switch 625NativeMethods.ProcessorArchitectures.X86 => CurrentMSBuildToolsDirectory, 626NativeMethods.ProcessorArchitectures.X64 or NativeMethods.ProcessorArchitectures.ARM64 629_ => 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;
Coordinator\CoordinatorSettings.cs (1)
141if (NativeMethods.IsWindows)
EncodingUtilities.cs (1)
229if (!NativeMethods.IsWindows)
FileUtilities.cs (12)
75public static bool IsFileSystemCaseSensitive => !(NativeMethods.IsWindows || NativeMethods.IsOSX); 209=> path.Length >= NativeMethods.MaxPath; // >= not > because MAX_PATH assumes a trailing null 215=> NativeMethods.IsUnixLike && path.IndexOf(WindowsDirectorySeparator) >= 0; 221=> NativeMethods.IsWindows && path.IndexOf(UnixDirectorySeparator) >= 0; 421if (NativeMethods.GetLastWriteDirectoryUtcTime(directoryPath, out lastModifiedTime)) 722if (NativeMethods.IsWindows || string.IsNullOrEmpty(value) 743if (NativeMethods.IsWindows || value.IsEmpty) 824if (NativeMethods.IsWindows) 952if (NativeMethods.IsWindows && !EndsWithSlash(fullPath)) 1428bool hasMaxPath = NativeMethods.HasMaxPath; 1429int maxPath = NativeMethods.MaxPath;
Globbing\GlobPattern.cs (1)
32bool unc = NativeMethods.IsWindows && fixedDirectory.StartsWith(@"\\", StringComparison.Ordinal);
ItemSpecModifiers.cs (1)
565if (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 (1)
37set => NativeMethods.SetCurrentDirectory(value.Value);
MultiThreadedTaskEnvironmentDriver.cs (1)
99if (!NativeMethods.IsWindows)
PathHelpers\AbsolutePath.cs (1)
136if (!NativeMethods.IsWindows
Traits.cs (1)
229(!NativeMethods.IsWindows && // Windows env vars are case-insensitive so no need to explicitly check
Utilities\AssemblyFolders\AssemblyFoldersEx.cs (1)
81if (!NativeMethods.IsWindows)
Utilities\FileMatcher.cs (9)
1155if (NativeMethods.IsLinux && recursionState.SearchData.DirectoryPattern != null) 2024if (NativeMethods.IsWindows && 2235NativeMethods.IsWindows 2827Math.Max(1, NativeMethods.GetLogicalCoreCount() / 2)); 2942filesystemCaseSensitive: NativeMethods.IsLinux && !matchForExclusion && !useCachedCallback, 2951useWin32FileNameMatch: NativeMethods.IsWindows 2955useWin32DirectoryMatch: NativeMethods.IsWindows 3039if (NativeMethods.IsWindows 3594var maxTasks = Math.Max(1, NativeMethods.GetLogicalCoreCount() / 2);
Utilities\FrameworkLocationHelper.cs (35)
73internal static string dotNetFrameworkVersionFolderPrefixV11 = NativeMethods.IsWindows ? "v1.1" : "1.1"; // v1.1 is for Everett. 78internal static string dotNetFrameworkVersionFolderPrefixV20 = NativeMethods.IsWindows ? "v2.0" : "2.0"; // v2.0 is for Whidbey. 82internal static string dotNetFrameworkVersionFolderPrefixV30 = NativeMethods.IsWindows ? "v3.0" : "3.0"; // v3.0 is for WinFx. 96internal static string dotNetFrameworkVersionFolderPrefixV35 = NativeMethods.IsWindows ? "v3.5" : "3.5"; // v3.5 is for Orcas. 102internal static string dotNetFrameworkVersionFolderPrefixV40 = NativeMethods.IsWindows ? "v4.0" : "4.0"; 103internal static string dotNetFrameworkVersionFolderPrefixV45 = NativeMethods.IsWindows ? "v4.5" : "4.5"; 424return NativeMethods.IsUnixLike 425? Path.Combine(NativeMethods.FrameworkBasePath, dotNetFrameworkVersionFolderPrefixV11) 434return NativeMethods.IsUnixLike 435? Path.Combine(NativeMethods.FrameworkBasePath, dotNetFrameworkVersionFolderPrefixV20) 444return NativeMethods.IsUnixLike 445? Path.Combine(NativeMethods.FrameworkBasePath, dotNetFrameworkVersionFolderPrefixV30) 454return NativeMethods.IsUnixLike 455? Path.Combine(NativeMethods.FrameworkBasePath, dotNetFrameworkVersionFolderPrefixV35) 464return NativeMethods.IsUnixLike 465? Path.Combine(NativeMethods.FrameworkBasePath, dotNetFrameworkVersionFolderPrefixV40) 474return NativeMethods.IsUnixLike 475? Path.Combine(NativeMethods.FrameworkBasePath, dotNetFrameworkVersionFolderPrefixV45) 484return NativeMethods.IsUnixLike 485? Path.Combine(NativeMethods.FrameworkBasePath, dotNetFrameworkVersionFolderPrefixV11) 494return NativeMethods.IsUnixLike 495? Path.Combine(NativeMethods.FrameworkBasePath, dotNetFrameworkVersionFolderPrefixV20) 518if (!NativeMethods.IsWindows) 520s_fallbackDotNetFrameworkSdkInstallPath = NativeMethods.FrameworkCurrentPath; 568if (NativeMethods.IsWindows) 615if (NativeMethods.IsWindows) 809if (!NativeMethods.IsWindows) 816var frameworkPath = Path.Combine(NativeMethods.FrameworkBasePath, prefix ?? string.Empty); 966combinedPath = NativeMethods.IsWindows 968: Path.Combine(NativeMethods.FrameworkBasePath, "xbuild-frameworks"); 1176dotNetFrameworkVersionFolderPrefix: NativeMethods.IsWindows ? "v4.0" : "v4.5", 1424string currentRuntimePath = NativeMethods.FrameworkCurrentPath; 1476if (NativeMethods.IsUnixLike) 1478string frameworkPath = NativeMethods.FrameworkBasePath; 1567if (NativeMethods.IsWindows)
Utilities\ProcessExtensions.cs (2)
116if (NativeMethods.IsWindows) 133else if (NativeMethods.IsLinux)
Utilities\ProcessorArchitecture.cs (11)
84=> NativeMethods.ProcessorArchitecture switch 86NativeMethods.ProcessorArchitectures.X86 => X86, 87NativeMethods.ProcessorArchitectures.X64 => AMD64, 88NativeMethods.ProcessorArchitectures.IA64 => IA64, 89NativeMethods.ProcessorArchitectures.ARM => ARM, 90NativeMethods.ProcessorArchitectures.ARM64 => ARM64, 91NativeMethods.ProcessorArchitectures.WASM => WASM, 92NativeMethods.ProcessorArchitectures.S390X => S390X, 93NativeMethods.ProcessorArchitectures.LOONGARCH64 => LOONGARCH64, 94NativeMethods.ProcessorArchitectures.ARMV6 => ARMV6, 95NativeMethods.ProcessorArchitectures.PPC64LE => PPC64LE,
Utilities\ToolLocationHelper_FrameworkPaths.cs (6)
355=> NativeMethods.ProcessorArchitectureNative switch 357NativeMethods.ProcessorArchitectures.X64 => ProcessorArchitecture.AMD64, 358NativeMethods.ProcessorArchitectures.IA64 => ProcessorArchitecture.IA64, 359NativeMethods.ProcessorArchitectures.ARM64 => ProcessorArchitecture.ARM64, 363NativeMethods.ProcessorArchitectures.X86 => null, 364NativeMethods.ProcessorArchitectures.ARM => null,
Utilities\ToolLocationHelper_ReferenceAssemblies.cs (1)
128if (NativeMethods.IsWindows && platformTarget != null)
Utilities\ToolLocationHelper_SDKDiscovery.cs (4)
62string registryRoot = NativeMethods.IsWindows ? GetTargetPlatformMonikerRegistryRoots(registrySearchLocation) : string.Empty; 81if (NativeMethods.IsWindows) 509if (NativeMethods.IsWindows) 531diskRoots.Add(NativeMethods.FrameworkBasePath);
Microsoft.Build.Tasks.Core (41)
AssemblyDependency\AssemblyInformation.cs (1)
308if (!NativeMethodsShared.IsWindows)
AssemblyDependency\AssemblyMetadata.cs (1)
30ScatterFiles = NativeMethodsShared.IsWindows ? import.Files : null;
AssemblyDependency\Node\NodePipeClient.cs (1)
18private static readonly bool s_useHandhakeTimeout = !NativeMethodsShared.IsWindows;
AssemblyDependency\Node\NodePipeServer.cs (1)
32private static readonly int s_handshakeTimeout = NativeMethodsShared.IsWindows ? 0 : 60_000;
AssemblyDependency\Reference.cs (1)
514else if (NativeMethodsShared.IsWindows)
AssemblyDependency\ResolveAssemblyReference.cs (1)
3858p => NativeMethodsShared.GetLastWriteFileUtcTime(p),
AssemblyInfo.cs (1)
4global using NativeMethodsShared = Microsoft.Build.Framework.NativeMethods;
Copy.cs (3)
45private static readonly int DefaultCopyParallelism = NativeMethodsShared.GetLogicalCoreCount() > 4 ? 6 : 4; 355TryCopyViaLink(SymbolicLinkComment, MessageImportance.Normal, sourceFileState, destinationFileState, out symbolicLinkCreated, ref errorMessage, (source, destination, errMessage) => NativeMethodsShared.MakeSymbolicLink(destination, source, ref errorMessage)); 358if (!NativeMethodsShared.IsWindows)
Exec.cs (7)
75if (NativeMethodsShared.IsUnixLike) 214if (!NativeMethodsShared.IsUnixLike) 259if (!NativeMethodsShared.IsUnixLike) 523if (NativeMethodsShared.IsWindows) 602if (NativeMethodsShared.IsUnixLike) 612if (NativeMethodsShared.IsWindows) 673protected 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)
284if (!NativeMethodsShared.IsWindows)
GenerateResource.cs (7)
1588DateTime outputTime = NativeMethodsShared.GetLastWriteFileUtcTime(outputFilePath); 1598DateTime sourceTime = NativeMethodsShared.GetLastWriteFileUtcTime(sourceFilePath); 1645DateTime linkedFileTime = NativeMethodsShared.GetLastWriteFileUtcTime(linkedFilePath); 1732DateTime sourceTime = NativeMethodsShared.GetLastWriteFileUtcTime(Sources[0].ItemSpec); 1733DateTime outputTime = NativeMethodsShared.GetLastWriteFileUtcTime(StronglyTypedFileName); 1791DateTime time = NativeMethodsShared.GetLastWriteFileUtcTime(input.ItemSpec); 2902if (!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)
SystemState.cs (1)
707return lastModified != DateTime.MinValue && lastModified != NativeMethodsShared.MinFileDate;
Unzip.cs (1)
273if (mode != UnixFileMode.None && NativeMethodsShared.IsUnixLike)
Microsoft.Build.Utilities.Core (6)
AssemblyInfo.cs (1)
4global using NativeMethodsShared = Microsoft.Build.Framework.NativeMethods;
ToolTask.cs (5)
669if (NativeMethodsShared.IsWindows) 804if (NativeMethodsShared.IsWindows) 1504bool runningOnWindows = NativeMethodsShared.IsWindows; 1566batchFileForCommandLine = NativeMethodsShared.GetShortFilePath(batchFileForCommandLine); 1733if (NativeMethodsShared.IsWindows)
MSBuild (25)
AssemblyInfo.cs (1)
4global using NativeMethodsShared = Microsoft.Build.Framework.NativeMethods;
CommandLine\CommandLineParser.cs (1)
287int numberOfCpus = NativeMethodsShared.GetLogicalCoreCount();
FilteredBinlogReplay.cs (2)
156NativeMethodsShared.IsWindows ? StringComparison.OrdinalIgnoreCase : StringComparison.Ordinal); 168HashSet<string> outputPaths = new(NativeMethodsShared.IsWindows ? StringComparer.OrdinalIgnoreCase : StringComparer.Ordinal);
OutOfProcTaskHostNode.cs (5)
1217NativeMethodsShared.SetCurrentDirectory(context.SavedCurrentDirectory); 1474NativeMethodsShared.SetCurrentDirectory(BuildEnvironmentHelper.Instance.CurrentMSBuildToolsDirectory); 1513NativeMethodsShared.SetCurrentDirectory(BuildEnvironmentHelper.Instance.CurrentMSBuildToolsDirectory); 1696NativeMethodsShared.SetCurrentDirectory(taskConfiguration.StartupDirectory); 1987isWindows: NativeMethodsShared.IsWindows);
XMake.cs (16)
1413NativeMethodsShared.RestoreConsoleMode(s_originalConsoleMode); 1449NativeMethodsShared.FrameworkName, 2179NativeMethodsShared.LongPathsStatus longPaths = NativeMethodsShared.IsLongPathsEnabled(); 2180if (longPaths != NativeMethodsShared.LongPathsStatus.NotApplicable) 2191NativeMethodsShared.SAC_State SAC_State = NativeMethodsShared.GetSACState(); 2192if (SAC_State != NativeMethodsShared.SAC_State.NotApplicable && SAC_State != NativeMethodsShared.SAC_State.Missing) 2364if (NativeMethodsShared.IsWindows && 2955(var acceptAnsiColorCodes, var outputIsScreen, s_originalConsoleMode) = NativeMethodsShared.QueryIsScreenAndTryEnableAnsiColorCodes(); 3108(_, _, s_originalConsoleMode) = NativeMethodsShared.QueryIsScreenAndTryEnableAnsiColorCodes(); 3774|| NativeMethodsShared.IsWindows 3791string physicalPwd = NativeMethodsShared.RealPath(logicalCurrentDirectory); 3792string physicalCwd = NativeMethodsShared.RealPath(Directory.GetCurrentDirectory()); 4770Console.WriteLine(ResourceUtilities.FormatResourceStringStripCodeAndKeyword("MSBuildVersionMessage", ProjectCollection.DisplayVersion, NativeMethods.FrameworkName));