Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Some more cleanups.
  • Loading branch information
teo-tsirpanis authored Sep 29, 2025
commit c601723506b084e5e7b013f7d23ddfb14b639ebf
10 changes: 4 additions & 6 deletions src/MSBuildLocator/DotNetSdkLocationHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ internal static partial class DotNetSdkLocationHelper
[GeneratedRegex(@"^(\d+)\.(\d+)\.(\d+)", RegexOptions.Multiline)]
private static partial Regex VersionRegex();

private static readonly string ExeName = OperatingSystem.IsWindows() ? "dotnet.exe" : "dotnet";
private static readonly Lazy<IList<string>> s_dotnetPathCandidates = new(() => ResolveDotnetPathCandidates());
private static string ExeName => OperatingSystem.IsWindows() ? "dotnet.exe" : "dotnet";
private static readonly Lazy<List<string>> s_dotnetPathCandidates = new(() => ResolveDotnetPathCandidates());

public static VisualStudioInstance? GetInstance(string dotNetSdkPath, bool allowQueryAllRuntimeVersions)
{
Expand Down Expand Up @@ -231,12 +231,12 @@ private static IntPtr HostFxrResolver(Assembly assembly, string libraryName)

private static string SdkResolutionExceptionMessage(string methodName) => $"Failed to find all versions of .NET Core MSBuild. Call to {methodName}. There may be more details in stderr.";

private static IList<string> ResolveDotnetPathCandidates()
private static List<string> ResolveDotnetPathCandidates()
{
var pathCandidates = new List<string>();
AddIfValid(GetDotnetPathFromROOT());

string? dotnetExePath = GetCurrentProcessPath();
string? dotnetExePath = Environment.ProcessPath;
bool isRunFromDotnetExecutable = !string.IsNullOrEmpty(dotnetExePath)
&& Path.GetFileName(dotnetExePath).Equals(ExeName, StringComparison.InvariantCultureIgnoreCase);

Expand Down Expand Up @@ -283,8 +283,6 @@ void AddIfValid(string? path)
return dotnetPath;
}

private static string? GetCurrentProcessPath() => Environment.ProcessPath;

private static string? GetDotnetPathFromPATH()
{
string? dotnetPath = null;
Expand Down
Loading