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

Most upvoted comments

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?”

“It has no work” - could you please clarify?

I apologize for the typo, it has TO work now 😄

@KirillOsenkov AFAICT @miloush is describing a different problem. You are wanting #10112.