Skip to content

SDK Resolution

Kirill Osenkov edited this page Jul 30, 2024 · 12 revisions

https://github.com/dotnet/sdk/issues/8254#issuecomment-859256628

https://github.com/dotnet/msbuild/pull/10282

https://github.com/dotnet/msbuild/issues/7988

https://learn.microsoft.com/en-us/dotnet/core/tools/dotnet-environment-variables

DOTNET_MSBUILD_SDK_RESOLVER_CLI_DIR

DOTNET_MSBUILD_SDK_RESOLVER_ENABLE_LOG

DOTNET_MSBUILD_SDK_RESOLVER_SDKS_DIR: Overrides the .NET SDK directory.

DOTNET_MSBUILD_SDK_RESOLVER_SDKS_VER: Overrides the .NET SDK version.

set PATH=C:\msbuild\.dotnet;%PATH%
set DOTNET_INSTALL_DIR=C:\msbuild\.dotnet
set DOTNET_MULTILEVEL_LOOKUP=0

Pre-release: https://github.com/dotnet/sdk/blob/544299b1466f508b041c7355f24b3215b4628991/src/Resolvers/Microsoft.DotNet.SdkResolver/VSSettings.cs#L23

MSBuildSDKsPath

MSBuildEnableWorkloadResolver

	Microsoft.Build	Microsoft.Build.BackEnd.SdkResolution.SdkResolverLoader.LoadResolverAssembly Line 246
	Microsoft.Build	Microsoft.Build.BackEnd.SdkResolution.SdkResolverLoader.LoadResolvers Line 272
	Microsoft.Build	Microsoft.Build.BackEnd.SdkResolution.SdkResolverLoader.LoadResolversFromManifest Line 259
	Microsoft.Build	Microsoft.Build.BackEnd.SdkResolution.CachingSdkResolverLoader.LoadResolversFromManifest Line 95
	mscorlib	System.Collections.Concurrent.ConcurrentDictionary`2.GetOrAdd
	Microsoft.Build	Microsoft.Build.BackEnd.SdkResolution.CachingSdkResolverLoader.LoadResolversFromManifest Line 95
	Microsoft.Build	Microsoft.Build.BackEnd.SdkResolution.SdkResolverService.GetResolvers Line 301
	Microsoft.Build	Microsoft.Build.BackEnd.SdkResolution.SdkResolverService.ResolveSdkUsingResolversWithPatternsFirst Line 252
	Microsoft.Build	Microsoft.Build.BackEnd.SdkResolution.SdkResolverService.ResolveSdk Line 170
	Microsoft.Build	Microsoft.Build.BackEnd.SdkResolution.CachingSdkResolverService.ResolveSdk Line 67
	mscorlib	System.Lazy`1.CreateValue
	mscorlib	System.Lazy`1.LazyInitValue
	mscorlib	System.Lazy`1.get_Value
	Microsoft.Build	Microsoft.Build.BackEnd.SdkResolution.CachingSdkResolverService.ResolveSdk Line 71
	Microsoft.Build	Microsoft.Build.Evaluation.Evaluator`4.ExpandAndLoadImportsFromUnescapedImportExpressionConditioned Line 1788
	Microsoft.Build	Microsoft.Build.Evaluation.Evaluator`4.ExpandAndLoadImports Line 1504
	Microsoft.Build	Microsoft.Build.Evaluation.Evaluator`4.EvaluateImportElement Line 1386
	Microsoft.Build	Microsoft.Build.Evaluation.Evaluator`4.PerformDepthFirstPass Line 910
	Microsoft.Build	Microsoft.Build.Evaluation.Evaluator`4.Evaluate Line 653
	Microsoft.Build	Microsoft.Build.Evaluation.Evaluator`4.Evaluate Line 339
	Microsoft.Build	Microsoft.Build.Evaluation.Project.ProjectImpl.Reevaluate Line 3737
	Microsoft.Build	Microsoft.Build.Evaluation.Project.ProjectImpl.ReevaluateIfNecessary Line 3690
	Microsoft.Build	Microsoft.Build.Evaluation.Project.ProjectImpl.ReevaluateIfNecessary Line 3673
	Microsoft.Build	Microsoft.Build.Evaluation.Project.ProjectImpl.ReevaluateIfNecessary Line 3306
	Microsoft.Build	Microsoft.Build.Evaluation.Project.ProjectImpl.Initialize Line 3809
	Microsoft.Build	Microsoft.Build.Evaluation.Project..ctor Line 473
	Microsoft.Build	Microsoft.Build.Evaluation.Project.FromFile Line 495

C:\Program Files\Microsoft Visual Studio\2022\Preview\MSBuild\Current\Bin\SdkResolvers\Microsoft.Build.NuGetSdkResolver\Microsoft.Build.NuGetSdkResolver.xml C:\Program Files\Microsoft Visual Studio\2022\Preview\Common7\IDE\CommonExtensions\Microsoft\NuGet\Microsoft.Build.NuGetSdkResolver.dll

C:\Program Files\Microsoft Visual Studio\2022\Preview\MSBuild\Current\Bin\SdkResolvers\Microsoft.DotNet.MSBuildSdkResolver\Microsoft.DotNet.MSBuildSdkResolver.dll C:\Program Files\Microsoft Visual Studio\2022\Preview\MSBuild\Current\Bin\SdkResolvers\Microsoft.DotNet.MSBuildSdkResolver\Microsoft.DotNet.MSBuildSdkResolver.dll

TryResolveSdkUsingSpecifiedResolvers

https://github.com/dotnet/sdk/blob/544299b1466f508b041c7355f24b3215b4628991/src/Resolvers/Microsoft.DotNet.NativeWrapper/EnvironmentProvider.cs#L57

''' Microsoft.DotNet.MSBuildSdkResolver Microsoft.DotNet.NativeWrapper.NETCoreSdkResolverNativeWrapper.ResolveSdk Line 23 Microsoft.DotNet.MSBuildSdkResolver Microsoft.DotNet.DotNetSdkResolver.NETCoreSdkResolver.ResolveNETCoreSdkDirectory Line 157 Microsoft.DotNet.MSBuildSdkResolver Microsoft.DotNet.MSBuildSdkResolver.DotNetMSBuildSdkResolver.Resolve Line 122 Microsoft.Build Microsoft.Build.BackEnd.SdkResolution.SdkResolverService.TryResolveSdkUsingSpecifiedResolvers Line 374 Microsoft.Build Microsoft.Build.BackEnd.SdkResolution.SdkResolverService.ResolveSdkUsingResolversWithPatternsFirst Line 257 Microsoft.Build Microsoft.Build.BackEnd.SdkResolution.SdkResolverService.ResolveSdk Line 170 Microsoft.Build Microsoft.Build.BackEnd.SdkResolution.CachingSdkResolverService.ResolveSdk Line 67 '''

https://github.com/dotnet/sdk/blob/544299b1466f508b041c7355f24b3215b4628991/src/Resolvers/Microsoft.DotNet.MSBuildSdkResolver/MSBuildSdkResolver.cs#L145