msbuild: Bootstrap MSBuild unable to build console projects: unable to resolve workload SDKs
Prep a bootstrap MSBuild layout using build /p:CreateBootstrap=true
or download the one I used from:
https://kirillosenkovfiles.blob.core.windows.net/kirillosenkovblob/msbuild.17.3.1.zip
Be on an empty Windows machine, such as Windows Sandbox VM
Create and build a new C# console app targeting net472
Expected: builds successfully
Actual:
Build FAILED.
C:\Users\WDAGUtilityAccount\AppData\Local\Bootstrap\MSBuild\Sdks\Microsoft.NET.Sdk\targets\Mic
rosoft.NET.Sdk.ImportWorkloads.props(14,3): error : Unable to locate the .NET SDK. Check that it is installed and that
the version specified in global.json (if any) matches the installed version.
C:\Users\WDAGUtilityAccount\AppData\Local\Bootstrap\MSBuild\Sdks\Microsoft.NET.Sdk\targets\Mic
rosoft.NET.Sdk.ImportWorkloads.targets(16,3): error : Unable to locate the .NET SDK. Check that it is installed and tha
t the version specified in global.json (if any) matches the installed version.
The two SDKs it can’t resolve:
Resolving SDK 'Microsoft.NET.SDK.WorkloadAutoImportPropsLocator'...
Resolving SDK 'Microsoft.NET.SDK.WorkloadManifestTargetsLocator'...
First off, the error messages are inadequate - they don’t mention the SDK reference that failed to resolve.
Both of these are supposed to resolve from: https://github.com/dotnet/sdk/blob/3dc5e528fffc050cace4cff8bc32954eb33f0455/src/Resolvers/Microsoft.NET.Sdk.WorkloadMSBuildSdkResolver/CachingWorkloadResolver.cs#L121-L136
However on an empty machine with just the xcopied MSBuild something goes awry apparently and it fails with the obscure messages above.
Until recently, the bootstrap MSBuild was xcopyable, meaning it used to build desktop-targeting projects on a completely empty Windows machine.
At some point this regressed. It is crucial that we continue to be able to have xcopyable MSBuild and we should move towards making MSBuild more portable, not less.
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Reactions: 5
- Comments: 27 (19 by maintainers)
Commits related to this issue
- Maybe permit failed SDK load If an SDK is a workload SDK, and we don't have the workload SDK resolver from the SDK, as, for instance, if we have an xcopy'd MSBuild, then we should still be able to bu... — committed to Forgind/msbuild by Forgind 3 years ago
- Disable workload resolver for net472 boostrap too This has been long done for .NET (core); extend it to the location that the .NET Framework copy of the SDK resolver looks for it too. Fixes #7988. — committed to rainersigwald/msbuild by rainersigwald 3 years ago
- Disable workload resolver for net472 bootstrap too (#10112) This has been long done for .NET (core); extend it to the location that the .NET Framework copy of the SDK resolver looks for it too. ... — committed to dotnet/msbuild by rainersigwald 3 years ago
- Disable workload resolver for amd64 too (#10118) Fixes #7988 Follow-up for ace4e4f3. — committed to dotnet/msbuild by KirillOsenkov 3 years ago
I’ll venmo $100 to whoever fixes this.
@JanKrivanek if there was one MSBuild issue that I’d love to see fixed the most, it’s this one
It’s super important for standalone bootstrap MSBuild to be able to build projects, and it’s currently not working. It’s super important to be able to check out any commit of MSBuild, build bootstrap and be able to use that MSBuild to build real projects.
It would be nice to prioritize this, because every release MSBuild ships, it ships being unable to work on an empty machine without the SDK installed. If it continues to be broken, we will be unable to just walk up to the MSBuild repo, build bootstrap and expect that it just works on any machine.
I normally like building and archiving bootstrapped MSBuild for every release, but the last working one I have is from 17.2 or something. This is also useful for bisecting, to answer questions like “which MSBuild release did this break in?”
Nothing seems to be logging anything into the SdkLogger.
This is never used for anything: https://github.com/dotnet/msbuild/blob/cc3db358d34ad4cd1ec0c67e17582d7ca2a15040/src/Build/BackEnd/Components/SdkResolution/SdkResolverService.cs#L259
I apologize for the typo, it has TO work now 😄
@KirillOsenkov AFAICT @miloush is describing a different problem. You are wanting #10112.