This PR changes to show details of errors that occur when the generator opens a project.
Currently, when an error occurs in the SDK resolver, the generator continues to proceed.
The error then occurs elsewhere, making it difficult to determine the cause.
Before
Project Compilation Start:MyProject
failed to get metadata of System.Threading.Tasks.Task`1
failed to get metadata of System.Threading.Tasks.Task
Fail in console app running on MessagepackCompiler.RunAsync
System.InvalidOperationException: failed to get metadata of MessagePack.MessagePackObjectAttribute
at MessagePackCompiler.CodeAnalysis.ReferenceSymbols..ctor(Compilation compilation, Action`1 logger) in C:\Users\path\to\MessagePack-CSharp\src\MessagePack.GeneratorCore\CodeAnalysis\TypeCollector.cs:line 53
at MessagePackCompiler.CodeAnalysis.TypeCollector..ctor(Compilation compilation, Boolean disallowInternal, Boolean isForceUseMap, String[] ignoreTypeNames, Action`1 logger) in C:\Users\path\to\MessagePack-CSharp\src\MessagePack.GeneratorCore\CodeAnalysis\TypeCollector.cs:line 259
After
Fail in console app running on MessagepackCompiler.RunAsync
System.InvalidOperationException: One or more errors occured while opening the project:
========================================
Msbuild failed when processing the file 'C:\Users\path\to\MyProject.csproj' with message: 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.4' is lower than version '6.0.9' required by manifest 'microsoft.net.workload.mono.toolchain' [C:\Program Files\dotnet\sdk-manifests\6.0.300\microsoft.net.workload.mono.toolchain\WorkloadManifest.json]
at Microsoft.NET.Sdk.WorkloadManifestReader.WorkloadResolver.ComposeWorkloadManifests()
at Microsoft.NET.Sdk.WorkloadManifestReader.WorkloadResolver.Create(IWorkloadManifestProvider manifestProvider, String dotnetRootPath, String sdkVersion, String userProfileDir)
at Microsoft.NET.Sdk.WorkloadMSBuildSdkResolver.CachingWorkloadResolver.Resolve(String sdkReferenceName, String dotnetRootPath, String sdkVersion, String userProfileDir)
at Microsoft.NET.Sdk.WorkloadMSBuildSdkResolver.WorkloadSdkResolver.Resolve(SdkReference sdkReference, SdkResolverContext resolverContext, SdkResultFactory factory)
at Microsoft.Build.BackEnd.SdkResolution.SdkResolverService.TryResolveSdkUsingSpecifiedResolvers(IList`1 resolvers, Int32 submissionId, SdkReference sdk, LoggingContext loggingContext, ElementLocation sdkReferenceLocation, String solutionPath, String projectPath, Boolean interactive, Boolean isRunningInVisualStudio, SdkResult& sdkResult)"" C:\Users\path\to\MyProject.csproj
========================================
at MessagePack.Generator.MessagepackCompiler.OpenMSBuildProjectAsync(String projectPath, CancellationToken cancellationToken) in C:\Users\path\to\MessagePack-CSharp\src\MessagePack.Generator\MessagepackCompiler.cs:line 96
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
This PR changes to show details of errors that occur when the generator opens a project.
Currently, when an error occurs in the SDK resolver, the generator continues to proceed.
The error then occurs elsewhere, making it difficult to determine the cause.
Before
After