diff --git a/UnoCheck/DotNet/DotNetSdk.cs b/UnoCheck/DotNet/DotNetSdk.cs index 1b97633e..d67b2ffe 100644 --- a/UnoCheck/DotNet/DotNetSdk.cs +++ b/UnoCheck/DotNet/DotNetSdk.cs @@ -68,12 +68,13 @@ public DotNetSdk(SharedState sharedState) if (Directory.Exists(envSdkRoot)) sdkRoot = envSdkRoot; } - - if (string.IsNullOrEmpty(sdkRoot) || !Directory.Exists(sdkRoot)) + + string environmentOverride = Environment.GetEnvironmentVariable("DOTNET_MSBUILD_SDK_RESOLVER_CLI_DIR"); + if (!string.IsNullOrEmpty(environmentOverride)) { - sdkRoot = Microsoft.DotNet.NativeWrapper.EnvironmentProvider.GetDotnetExeDirectory(); + sdkRoot = environmentOverride; } - + if (string.IsNullOrEmpty(sdkRoot) || !Directory.Exists(sdkRoot)) { var l = FindDotNetLocations(); @@ -83,6 +84,11 @@ public DotNetSdk(SharedState sharedState) } } + if (string.IsNullOrEmpty(sdkRoot) || !Directory.Exists(sdkRoot)) + { + sdkRoot = Microsoft.DotNet.NativeWrapper.EnvironmentProvider.GetDotnetExeDirectory(log: (s) => Util.Log(s.ToString())); + } + sharedState.SetEnvironmentVariable("DOTNET_ROOT", sdkRoot); // First try and use the actual resolver logic