dotnet / msbuild

The Microsoft Build Engine (MSBuild) is the build platform for .NET and Visual Studio.
https://docs.microsoft.com/visualstudio/msbuild/msbuild
MIT License
5.22k stars 1.35k forks source link

WorkloadManifestCompositionException stack dumped from SdkResolverService #6964

Open danmoseley opened 3 years ago

danmoseley commented 3 years ago

From a customer using Version 17.0.0 Preview 5.0 [31807.328.d17.0], their machine got into some bad state, and they get this output.

Assuming this is not indicating a bug in MSBuild, but rather a bad machine state, the exception should be caught so that only the error message is shown.

C:\temp\ConsoleApp1\ConsoleApp1>dotnet run
C:\temp\ConsoleApp1\ConsoleApp1\ConsoleApp1.csproj : error MSB4242: SDK Resolver Failure: "The SDK resolver "Microsoft.DotNet.MSBuildWorkloadSdkResolver" failed while attempting to resolve the SDK "Microsoft.NET.Sdk". Exception: "Microsoft.NET.Sdk.WorkloadManifestReader.WorkloadManifestCompositionException: Workload manifest dependency 'Microsoft.NET.Workload.Emscripten' version '6.0.0-rc.2.21474.1' is lower than version '6.0.0-rc.1.21430.3' required by manifest 'microsoft.net.workload.mono.toolchain' [C:\Program Files\dotnet\sdk-manifests\6.0.100\microsoft.net.workload.mono.toolchain\WorkloadManifest.json]
C:\temp\ConsoleApp1\ConsoleApp1\ConsoleApp1.csproj : error MSB4242:    at Microsoft.NET.Sdk.WorkloadManifestReader.WorkloadResolver.ComposeWorkloadManifests()
C:\temp\ConsoleApp1\ConsoleApp1\ConsoleApp1.csproj : error MSB4242:    at Microsoft.NET.Sdk.WorkloadManifestReader.WorkloadResolver.Create(IWorkloadManifestProvider manifestProvider, String dotnetRootPath, String sdkVersion, String userProfileDir)
C:\temp\ConsoleApp1\ConsoleApp1\ConsoleApp1.csproj : error MSB4242:    at Microsoft.NET.Sdk.WorkloadMSBuildSdkResolver.CachingWorkloadResolver.Resolve(String sdkReferenceName, String dotnetRootPath, String sdkVersion, String userProfileDir)
C:\temp\ConsoleApp1\ConsoleApp1\ConsoleApp1.csproj : error MSB4242:    at Microsoft.NET.Sdk.WorkloadMSBuildSdkResolver.WorkloadSdkResolver.Resolve(SdkReference sdkReference, SdkResolverContext resolverContext, SdkResultFactory factory)
C:\temp\ConsoleApp1\ConsoleApp1\ConsoleApp1.csproj : error MSB4242:    at Microsoft.Build.BackEnd.SdkResolution.SdkResolverService.ResolveSdk(Int32 submissionId, SdkReference sdk, LoggingContext loggingContext, ElementLocation sdkReferenceLocation, String solutionPath, String projectPath, Boolean interactive, Boolean isRunningInVisualStudio)""
Forgind commented 2 years ago

This is where that error is thrown. As you can see, we're already throwing just the message, but "e.Message already contains the stack trace" as indicated in the comment. I don't think it's worth it to parse the message to extract just the actual message part; ultimately, this gives the user access to all the information they need, just with some extra.

Reasonable to close?

danmoseley commented 2 years ago

The bug then is that the exception message contains the stack. I agree it's low priority.