Closed
Description
First found here: dotnet/msbuild#8674 (comment)
Describe the bug
API Compat shares some dependencies with Roslyn. Those that are in the framework should get unified on our behalf. Those that are carried with the task will not. The task tries to unify them (it has a deps file) but this won't work if Roslyn uses versions higher than the task. We might consider loading the versions from Roslyn instead of those in the SDK.
To Reproduce
Using 7.0 GA sdk, try to have the task use latest compiler (for example with the compilers nuget package). Apparently this can happen with some combination of SDK / VS version.
Exceptions (if any)
D:\a\1\s\.dotnet\sdk\7.0.203\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.ApiCompat.ValidatePackage.targets(39,5): error MSB4018: The "Microsoft.DotNet.ApiCompat.Task.ValidatePackageTask" task failed unexpectedly.
System.MissingMethodException: Method not found: 'Void Microsoft.CodeAnalysis.CSharp.CSharpCompilationOptions..ctor(Microsoft.CodeAnalysis.OutputKind, Boolean, System.String, System.String, System.String, System.Collections.Generic.IEnumerable`1<System.String>, Microsoft.CodeAnalysis.OptimizationLevel, Boolean, Boolean, System.String, System.String, System.Collections.Immutable.ImmutableArray`1<Byte>, System.Nullable`1<Boolean>, Microsoft.CodeAnalysis.Platform, Microsoft.CodeAnalysis.ReportDiagnostic, Int32, System.Collections.Generic.IEnumerable`1<System.Collections.Generic.KeyValuePair`2<System.String,Microsoft.CodeAnalysis.ReportDiagnostic>>, Boolean, Boolean, Microsoft.CodeAnalysis.XmlReferenceResolver, Microsoft.CodeAnalysis.SourceReferenceResolver, Microsoft.CodeAnalysis.MetadataReferenceResolver, Microsoft.CodeAnalysis.AssemblyIdentityComparer, Microsoft.CodeAnalysis.StrongNameProvider, Boolean, Microsoft.CodeAnalysis.MetadataImportOptions, Microsoft.CodeAnalysis.NullableContextOptions)'.
at Microsoft.DotNet.ApiCompatibility.AssemblySymbolLoader..ctor(Boolean resolveAssemblyReferences)
at Microsoft.DotNet.ApiCompatibility.AssemblySymbolLoaderFactory.Create(Boolean shouldResolveReferences)
at Microsoft.DotNet.ApiCompatibility.Runner.ApiCompatRunner.CreateAssemblySymbols(IReadOnlyList`1 metadataInformation, ApiCompatRunnerOptions options, Boolean& resolvedExternallyProvidedAssemblyReferences)
at Microsoft.DotNet.ApiCompatibility.Runner.ApiCompatRunner.ExecuteWorkItems()
at Microsoft.DotNet.ApiCompat.ValidatePackage.Run(Func`2 logFactory, Boolean generateSuppressionFile, String[] suppressionFiles, String suppressionOutputFile, String noWarn, Boolean enableRuleAttributesMustMatch, String[] excludeAttributesFiles, Boolean enableRuleCannotChangeParameterName, String packagePath, Boolean runApiCompat, Boolean enableStrictModeForCompatibleTfms, Boolean enableStrictModeForCompatibleFrameworksInPackage, Boolean enableStrictModeForBaselineValidation, String baselinePackagePath, String runtimeGraph, Dictionary`2 packageAssemblyReferences, Dictionary`2 baselinePackageAssemblyReferences)
at Microsoft.DotNet.ApiCompat.Task.ValidatePackageTask.ExecuteCore()
at Microsoft.NET.Build.Tasks.TaskBase.Execute()
at Microsoft.DotNet.ApiCompat.Task.ValidatePackageTask.Execute()
at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__26.MoveNext()
Further technical details
- Include the output of
dotnet --info
- The IDE (VS / VS Code/ VS4Mac) you're running on, and its version