diff --git a/documentation/wiki/ChangeWaves.md b/documentation/wiki/ChangeWaves.md index 6282a09e7b1..ec84d18521a 100644 --- a/documentation/wiki/ChangeWaves.md +++ b/documentation/wiki/ChangeWaves.md @@ -29,6 +29,7 @@ A wave of features is set to "rotate out" (i.e. become standard functionality) t - [Cache SDK resolver data process-wide](https://github.com/dotnet/msbuild/pull/9335) - [Target parameters will be unquoted](https://github.com/dotnet/msbuild/pull/9452), meaning the ';' symbol in the parameter target name will always be treated as separator - [Change Version switch output to finish with a newline](https://github.com/dotnet/msbuild/pull/9485) +- [Load Microsoft.DotNet.MSBuildSdkResolver into default load context (MSBuild.exe only)](https://github.com/dotnet/msbuild/pull/9439) ### 17.8 - [[RAR] Don't do I/O on SDK-provided references](https://github.com/dotnet/msbuild/pull/8688) diff --git a/src/Build/BackEnd/Components/SdkResolution/SdkResolverLoader.cs b/src/Build/BackEnd/Components/SdkResolution/SdkResolverLoader.cs index 3c5349611c1..25039ccd712 100644 --- a/src/Build/BackEnd/Components/SdkResolution/SdkResolverLoader.cs +++ b/src/Build/BackEnd/Components/SdkResolution/SdkResolverLoader.cs @@ -226,6 +226,20 @@ protected virtual IEnumerable GetResolverTypes(Assembly assembly) protected virtual Assembly LoadResolverAssembly(string resolverPath) { #if !FEATURE_ASSEMBLYLOADCONTEXT + if (ChangeWaves.AreFeaturesEnabled(ChangeWaves.Wave17_10)) + { + string resolverFileName = Path.GetFileNameWithoutExtension(resolverPath); + if (resolverFileName.Equals("Microsoft.DotNet.MSBuildSdkResolver", StringComparison.OrdinalIgnoreCase)) + { + // This will load the resolver assembly into the default load context if possible, and fall back to LoadFrom context. + // We very much prefer the default load context because it allows native images to be used by the CLR, improving startup perf. + AssemblyName assemblyName = new AssemblyName(resolverFileName) + { + CodeBase = resolverPath, + }; + return Assembly.Load(assemblyName); + } + } return Assembly.LoadFrom(resolverPath); #else return s_loader.LoadFromPath(resolverPath); diff --git a/src/MSBuild/app.amd64.config b/src/MSBuild/app.amd64.config index 1feab29307d..34c409fa079 100644 --- a/src/MSBuild/app.amd64.config +++ b/src/MSBuild/app.amd64.config @@ -184,6 +184,21 @@ + + + + + + + + + + + + + + + diff --git a/src/MSBuild/app.config b/src/MSBuild/app.config index 51d2a26861e..cb3e75d2510 100644 --- a/src/MSBuild/app.config +++ b/src/MSBuild/app.config @@ -133,6 +133,21 @@ + + + + + + + + + + + + + + +