msbuild: Unable to build using bootstrap: Method not found: 'NuGet.ProjectModel.LockFile.GetTarget'
I have installed VS 16.9.2 on my local machine and now my bootstrapped MSBuild no longer works:
C:\Program Files\dotnet\sdk\5.0.201\Sdks\Microsoft.NET.Sdk\targets\Microsoft.PackageDependencyResolution.targets(241,5): error MSB4018: The "ResolvePackageAssets" task failed unexpectedly.
System.MissingMethodException: Method not found: 'NuGet.ProjectModel.LockFileTarget NuGet.ProjectModel.LockFile.GetTarget(NuGet.Frameworks.NuGetFramework, System.String)'.
at Microsoft.NET.Build.Tasks.LockFileExtensions.GetTargetAndReturnNullIfNotFound(LockFile lockFile, String frameworkAlias, String runtimeIdentifier)
at Microsoft.NET.Build.Tasks.LockFileExtensions.GetTargetAndThrowIfNotFound(LockFile lockFile, String frameworkAlias, String runtimeIdentifier)
at Microsoft.NET.Build.Tasks.ResolvePackageAssets.CacheWriter..ctor(ResolvePackageAssets task)
at Microsoft.NET.Build.Tasks.ResolvePackageAssets.CacheReader.CreateReaderFromDisk(ResolvePackageAssets task, Byte[] settingsHash)
at Microsoft.NET.Build.Tasks.ResolvePackageAssets.CacheReader..ctor(ResolvePackageAssets task)
at Microsoft.NET.Build.Tasks.ResolvePackageAssets.ReadItemGroups()
at Microsoft.NET.Build.Tasks.ResolvePackageAssets.ExecuteCore()
at Microsoft.NET.Build.Tasks.TaskBase.Execute()
at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute() in C:\msbuild\src\Build\BackEnd\TaskExecutionHost\TaskExecutionHost.cs:line 585
at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__26.MoveNext() in C:\msbuild\src\Build\BackEnd\Components\RequestBuilder\TaskBuilder.cs:line 809 [C:\temp\net472\net472.csproj]
Looks like it’s some binary incompatibility?
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 18 (17 by maintainers)
I have taken some traces of the good and bad cases. Interestingly,
NuGet.Frameworks.dll
gets loaded twice in both the good and bad cases. The actual DLL path is different, but the files are identical, and the requested load versions are identical. However, the load context within the runtime is different. My expectation is that this would work, but obviously it is not.The
MissingMethodException
is forNuGet.ProjectModel.LockFileTarget NuGet.ProjectModel.LockFile.GetTarget(NuGet.Frameworks.NuGetFramework, System.String)
. I have also confirmed thatNuGet.ProjectModel.dll
is only loaded once and the location of the load is the same in both the good and the bad cases.In the functional case, there is one more assembly load than in the failed case:
C:\src\msbuild\artifacts\bin\bootstrap\net472\MSBuild\Current\Bin\Roslyn\Microsoft.Build.Tasks.CodeAnalysis.dll
This assembly, and none of it’s transitive dependencies depend upon any of the NuGet dlls.I suspect that I’m going to need to get some more loader expertise on this. I’ll report back on what I find out.
The
LockFile.GetTarget
method is from NuGet, the SDK extension methods are wrappers around it.I’m not sure why this would be breaking, but try to figure out what version of the NuGet APIs are being used in the bootstrapped MSBuild.