Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #6289
Context
#6126 changes the way that
NuGet.Frameworks.dllis loaded to be used byNuGetFrameworkWrapperfrom a call toLoadFileto a call toLoadFrom. The path passed in to theLoad*` call is the same in both cases, but the behavior is different when running on .NET Framework.On .NET Framework, calling
LoadFileresults in IJW loading rules being followed, and a different copy ofNuGet.Frameworks.dllthan the one requested being loaded. It also appears to match the one loaded into the LOAD context. Calling
LoadFromresults in the specified assembly being loaded, but it doesn't match the copy of the assembly loaded into the LOAD context. Thus, it remains in the LOADFROM context instead of being promoted to the LOAD context.Later on, there is a collision between code from the two instances of
NuGet.Frameworks.dllthat are loaded into the LOAD context and the LOADFROM context, and this is where theMissingMethodExceptionis thrown.Note, this does not happen on the .NET Core bootstrap build because the loader behavior is significantly simpler.
Changes Made
Choose the
Load*API based on the target framework at build time. On .NET Core, useLoadFromand on .NET Framework, useLoadFile. This type of precedent already exists in MSBuild where there is different load behavior for .NET Framework and .NET Core.Testing
Tested local bootstrap builds that were built on .NET Framework and .NET Core using the repro in #6289.