Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[main] Update dependencies from dotnet/roslyn #8674

Merged
merged 13 commits into from
May 23, 2023

Conversation

dotnet-maestro[bot]
Copy link
Contributor

@dotnet-maestro dotnet-maestro bot commented Apr 18, 2023

This pull request updates the following dependencies

From https://github.com/dotnet/roslyn

  • Subscription: 848bf81b-14ec-482f-6736-08da008bd46a
  • Build: 20230521.1
  • Date Produced: May 21, 2023 4:16:32 PM UTC
  • Commit: 687921ffae8ad91a5464473cb1759fd463c345f2
  • Branch: refs/heads/main

dotnet-maestro bot and others added 2 commits April 18, 2023 16:03
…417.19

Microsoft.Net.Compilers.Toolset
 From Version 4.6.0-2.23171.5 -> To Version 4.7.0-1.23217.19
@lewing
Copy link
Member

lewing commented Apr 21, 2023

@rainersigwald any idea what is going on here

cc @jaredpar

@rainersigwald
Copy link
Member

Adapted to dotnet/roslyn#67747.

@lewing any particular reason you were looking at this?

@lewing
Copy link
Member

lewing commented Apr 21, 2023

just trying to make sure there is nothing more hiding in the package flow ahead of preview.4 freeze

@rainersigwald rainersigwald force-pushed the darc-main-a0aec00d-d482-4e39-96c7-5aacd70aca5b branch from 3fe57e3 to dc5864d Compare April 21, 2023 20:59
@rainersigwald
Copy link
Member

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() 

It amuses me that the package-binary-compat-check task is failing with a binary compat failure, but . . . what?

@lewing
Copy link
Member

lewing commented Apr 23, 2023

@dotnet/roslyn-analysis could someone take a look?

lewing and others added 2 commits April 23, 2023 14:15
…422.1

Microsoft.Net.Compilers.Toolset
 From Version 4.6.0-2.23171.5 -> To Version 4.7.0-1.23222.1
@lewing
Copy link
Member

lewing commented Apr 26, 2023

cc @dotnet/dnr-codeflow

Copy link
Member

@arkalyanms arkalyanms left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks fine to me. I believe there is a validation book associated with this update. @mavasani to approve as well.

@rainersigwald
Copy link
Member

I can repro the failure when building from 17.5.

fuslog:

=== Pre-bind state information ===
LOG: DisplayName = Microsoft.DotNet.ApiCompatibility, Version=7.0.203.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51
 (Fully-specified)
LOG: Appbase = file:///C:/Program Files/Microsoft Visual Studio/2022/Enterprise/MSBuild/Current/Bin/amd64/
LOG: Initial PrivatePath = NULL
LOG: Dynamic Base = NULL
LOG: Cache Base = NULL
LOG: AppName = MSBuild.exe
Calling assembly : Microsoft.DotNet.ApiCompat.Task, Version=7.0.203.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51.
===
LOG: This bind starts in LoadFrom load context.
WRN: Native image will not be probed in LoadFrom context. Native image will only be probed in default load context, like with Assembly.Load().
LOG: Using application configuration file: C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Current\Bin\amd64\MSBuild.exe.Config
LOG: Using host configuration file: 
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework64\v4.0.30319\config\machine.config.
LOG: Post-policy reference: Microsoft.DotNet.ApiCompatibility, Version=7.0.203.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51
LOG: GAC Lookup was unsuccessful.
LOG: Attempting download of new URL file:///C:/Program Files/Microsoft Visual Studio/2022/Enterprise/MSBuild/Current/Bin/amd64/Microsoft.DotNet.ApiCompatibility.DLL.
LOG: Attempting download of new URL file:///C:/Program Files/Microsoft Visual Studio/2022/Enterprise/MSBuild/Current/Bin/amd64/Microsoft.DotNet.ApiCompatibility/Microsoft.DotNet.ApiCompatibility.DLL.
LOG: Attempting download of new URL file:///C:/Program Files/Microsoft Visual Studio/2022/Enterprise/MSBuild/Current/Bin/amd64/Microsoft.DotNet.ApiCompatibility.EXE.
LOG: Attempting download of new URL file:///C:/Program Files/Microsoft Visual Studio/2022/Enterprise/MSBuild/Current/Bin/amd64/Microsoft.DotNet.ApiCompatibility/Microsoft.DotNet.ApiCompatibility.EXE.
LOG: Attempting download of new URL file:///C:/src/msbuild/.dotnet/sdk/7.0.203/Sdks/Microsoft.NET.Sdk/tools/net472/Microsoft.DotNet.ApiCompatibility.DLL.
LOG: Assembly download was successful. Attempting setup of file: C:\src\msbuild\.dotnet\sdk\7.0.203\Sdks\Microsoft.NET.Sdk\tools\net472\Microsoft.DotNet.ApiCompatibility.dll
LOG: Entering run-from-source setup phase.
LOG: Assembly Name is: Microsoft.DotNet.ApiCompatibility, Version=7.0.203.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51
LOG: Where-ref bind Codebase does not match what is found in default context. Keep the result in LoadFrom context.
LOG: Binding succeeds. Returns assembly from C:\src\msbuild\.dotnet\sdk\7.0.203\Sdks\Microsoft.NET.Sdk\tools\net472\Microsoft.DotNet.ApiCompatibility.dll.
LOG: Assembly is loaded in LoadFrom load context.
=== Pre-bind state information ===
LOG: DisplayName = Microsoft.CodeAnalysis.CSharp, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
 (Fully-specified)
LOG: Appbase = file:///C:/Program Files/Microsoft Visual Studio/2022/Enterprise/MSBuild/Current/Bin/amd64/
LOG: Initial PrivatePath = NULL
LOG: Dynamic Base = NULL
LOG: Cache Base = NULL
LOG: AppName = MSBuild.exe
Calling assembly : Microsoft.DotNet.ApiCompatibility, Version=7.0.203.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51.
===
LOG: This bind starts in LoadFrom load context.
WRN: Native image will not be probed in LoadFrom context. Native image will only be probed in default load context, like with Assembly.Load().
LOG: Using application configuration file: C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Current\Bin\amd64\MSBuild.exe.Config
LOG: Using host configuration file: 
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework64\v4.0.30319\config\machine.config.
LOG: Post-policy reference: Microsoft.CodeAnalysis.CSharp, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
LOG: GAC Lookup was unsuccessful.
LOG: Attempting download of new URL file:///C:/Program Files/Microsoft Visual Studio/2022/Enterprise/MSBuild/Current/Bin/amd64/Microsoft.CodeAnalysis.CSharp.DLL.
LOG: Attempting download of new URL file:///C:/Program Files/Microsoft Visual Studio/2022/Enterprise/MSBuild/Current/Bin/amd64/Microsoft.CodeAnalysis.CSharp/Microsoft.CodeAnalysis.CSharp.DLL.
LOG: Attempting download of new URL file:///C:/Program Files/Microsoft Visual Studio/2022/Enterprise/MSBuild/Current/Bin/amd64/Microsoft.CodeAnalysis.CSharp.EXE.
LOG: Attempting download of new URL file:///C:/Program Files/Microsoft Visual Studio/2022/Enterprise/MSBuild/Current/Bin/amd64/Microsoft.CodeAnalysis.CSharp/Microsoft.CodeAnalysis.CSharp.EXE.
LOG: Attempting download of new URL file:///C:/src/msbuild/.dotnet/sdk/7.0.203/Sdks/Microsoft.NET.Sdk/tools/net472/Microsoft.CodeAnalysis.CSharp.DLL.
LOG: Attempting download of new URL file:///C:/src/msbuild/.dotnet/sdk/7.0.203/Sdks/Microsoft.NET.Sdk/tools/net472/Microsoft.CodeAnalysis.CSharp/Microsoft.CodeAnalysis.CSharp.DLL.
LOG: Attempting download of new URL file:///C:/src/msbuild/.dotnet/sdk/7.0.203/Sdks/Microsoft.NET.Sdk/tools/net472/Microsoft.CodeAnalysis.CSharp.EXE.
LOG: Attempting download of new URL file:///C:/src/msbuild/.dotnet/sdk/7.0.203/Sdks/Microsoft.NET.Sdk/tools/net472/Microsoft.CodeAnalysis.CSharp/Microsoft.CodeAnalysis.CSharp.EXE.
LOG: All probing URLs attempted and failed.

From a successful binlog it finds CodeAnalysis.CSharp in the package folder, maybe because it's using the toolset package all the time?

Microsoft.DotNet.ApiCompat.Task.ValidatePackageTask
    Assembly = S:\msbuild\.dotnet\sdk\7.0.203\Sdks\Microsoft.NET.Sdk\targets\..\tools\net472\Microsoft.DotNet.ApiCompat.Task.dll
    Parameters
        NoWarn = ;1701;1702;1705;1591;NU1507;NU1603;NU5105;1701;1702;SYSLIB0011;SYSLIB0037;SYSLIB0044;RS0016;RS0017;;NU5131;1570;1572;1573;1587;IL2121;1701;1702
        RuntimeGraph = S:\msbuild\.dotnet\sdk\7.0.203\RuntimeIdentifierGraph.json
        EnableStrictModeForCompatibleTfms = True
        PackageAssemblyReferences
            net472
                MSBuildSourceProjectFile = S:\msbuild\src\Deprecated\Conversion\Microsoft.Build.Conversion.csproj
                ReferencePath = S:\msbuild\.packages\microsoft.bcl.asyncinterfaces\7.0.0\lib\net462\Microsoft.Bcl.AsyncInterfaces.dll,S:\msbuild\artifacts\obj\Microsoft.Build\Release\net472\ref\Microsoft.Build.dll,S:\msbuild\artifacts\obj\Microsoft.Build.Engine\Release\net472\ref\Microsoft.Build.Engine.dll,S:\msbuild\artifacts\obj\Microsoft.Build.Framework\Release\net472\ref\Microsoft.Build.Framework.dll,S:\msbuild\.packages\microsoft.io.redist\6.0.0\lib\net472\Microsoft.IO.Redist.dll,S:\msbuild\artifacts\obj\StringTools\Release\net472\ref\Microsoft.NET.StringTools.dll,S:\msbuild\.packages\microsoft.visualstudio.setup.configuration.interop\3.2.2146\lib\net35\Microsoft.VisualStudio.Setup.Configuration.Interop.dll,C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.7.2\mscorlib.dll,S:\msbuild\.packages\system.buffers\4.5.1\ref\net45\System.Buffers.dll,S:\msbuild\.packages\system.collections.immutable\7.0.0\lib\net462\System.Collections.Immutable.dll,S:\msbuild\.packages\system.configuration.configurationmanager\7.0.0\lib\net462\System.Configuration.ConfigurationManager.dll,C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.7.2\System.Configuration.dll,C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.7.2\System.Core.dll,C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.7.2\System.Data.dll,C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.7.2\System.Data.OracleClient.dll,C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.7.2\System.dll,C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.7.2\System.Drawing.dll,C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.7.2\System.IO.Compression.FileSystem.dll,S:\msbuild\.packages\system.memory\4.5.5\lib\net461\System.Memory.dll,C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.7.2\System.Net.dll,C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.7.2\System.Numerics.dll,S:\msbuild\.packages\system.numerics.vectors\4.5.0\ref\net46\System.Numerics.Vectors.dll,S:\msbuild\.packages\system.reflection.metadata\7.0.0\lib\net462\System.Reflection.Metadata.dll,S:\msbuild\.packages\system.reflection.metadataloadcontext\7.0.0\lib\net462\System.Reflection.MetadataLoadContext.dll,S:\msbuild\.packages\system.runtime.compilerservices.unsafe\6.0.0\lib\net461\System.Runtime.CompilerServices.Unsafe.dll,C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.7.2\System.Runtime.Serialization.dll,S:\msbuild\.packages\system.security.accesscontrol\6.0.0\lib\net461\System.Security.AccessControl.dll,C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.7.2\System.Security.dll,S:\msbuild\.packages\system.security.permissions\7.0.0\lib\net462\System.Security.Permissions.dll,S:\msbuild\.packages\system.security.principal.windows\5.0.0\ref\net461\System.Security.Principal.Windows.dll,C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.7.2\System.ServiceProcess.dll,S:\msbuild\.packages\system.text.encodings.web\7.0.0\lib\net462\System.Text.Encodings.Web.dll,S:\msbuild\.packages\system.text.json\7.0.0\lib\net462\System.Text.Json.dll,S:\msbuild\.packages\system.threading.tasks.dataflow\7.0.0\lib\net462\System.Threading.Tasks.Dataflow.dll,S:\msbuild\.packages\system.threading.tasks.extensions\4.5.4\lib\net461\System.Threading.Tasks.Extensions.dll,C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.7.2\System.Transactions.dll,S:\msbuild\.packages\system.valuetuple\4.5.0\ref\net47\System.ValueTuple.dll,C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.7.2\System.Xml.dll,C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.7.2\System.Xml.Linq.dll,C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.7.2\WindowsBase.dll
                MSBuildSourceTargetName = GetReferencesForApiCompatValidatePackage
                OriginalItemSpec = S:\msbuild\src\Deprecated\Conversion\Microsoft.Build.Conversion.csproj
        RoslynAssembliesPath = S:\msbuild\.packages\microsoft.net.compilers.toolset\4.7.0-1.23222.1\build\..\tasks\net472
        BaselinePackageTargetPath = S:\msbuild\.packages\microsoft.build.conversion.core\17.6.0-preview-23178-11\microsoft.build.conversion.core.17.6.0-preview-23178-11.nupkg
        PackageTargetPath = S:\msbuild\artifacts\packages\Release\Shipping\Microsoft.Build.Conversion.Core.17.7.0-ci-23226-01.nupkg
    Assembly loaded during TaskRun (Microsoft.DotNet.ApiCompat.Task.ValidatePackageTask): Microsoft.DotNet.ApiCompatibility, Version=7.0.203.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51 (location: S:\msbuild\.dotnet\sdk\7.0.203\Sdks\Microsoft.NET.Sdk\tools\net472\Microsoft.DotNet.ApiCompatibility.dll, MVID: 1186e573-360e-4311-85c4-e06be7671abe, AppDomain: [Default])
    Assembly loaded during TaskRun (Microsoft.DotNet.ApiCompat.Task.ValidatePackageTask): Microsoft.DotNet.PackageValidation, Version=7.0.203.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51 (location: S:\msbuild\.dotnet\sdk\7.0.203\Sdks\Microsoft.NET.Sdk\tools\net472\Microsoft.DotNet.PackageValidation.dll, MVID: f82d0ce8-6232-4921-8384-216e76b6e042, AppDomain: [Default])
    Assembly loaded during TaskRun (Microsoft.DotNet.ApiCompat.Task.ValidatePackageTask): Microsoft.GeneratedCode, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null (location: , MVID: 9d7171fc-3146-44a9-983b-06a8784e807a, AppDomain: [Default])
    Assembly loaded during TaskRun (Microsoft.DotNet.ApiCompat.Task.ValidatePackageTask): Microsoft.CodeAnalysis, Version=4.7.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35 (location: S:\msbuild\.packages\microsoft.net.compilers.toolset\4.7.0-1.23222.1\tasks\net472\Microsoft.CodeAnalysis.dll, MVID: a8098514-21d5-4409-a050-924b3469ed11, AppDomain: [Default])
    Assembly loaded during TaskRun (Microsoft.DotNet.ApiCompat.Task.ValidatePackageTask): Microsoft.CodeAnalysis.CSharp, Version=4.7.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35 (location: S:\msbuild\.packages\microsoft.net.compilers.toolset\4.7.0-1.23222.1\tasks\net472\Microsoft.CodeAnalysis.CSharp.dll, MVID: 17cfe251-bc40-4386-bef5-6d1cd74060a3, AppDomain: [Default])
    Assembly loaded during TaskRun (Microsoft.DotNet.ApiCompat.Task.ValidatePackageTask): netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51 (location: C:\Windows\Microsoft.Net\assembly\GAC_MSIL\netstandard\v4.0_2.0.0.0__cc7b13ffcd2ddd51\netstandard.dll, MVID: 3a290359-4df5-45f3-88c2-228a7d84185a, AppDomain: [Default])
    Executing 1 work item(s)...
    Assembly loaded during TaskRun (Microsoft.DotNet.ApiCompat.Task.ValidatePackageTask): System.ValueTuple, Version=4.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51 (location: C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.ValueTuple\v4.0_4.0.0.0__cc7b13ffcd2ddd51\System.ValueTuple.dll, MVID: 1b57dc61-2a2b-406d-bb2c-afd7e8e5e6af, AppDomain: [Default])

@rainersigwald
Copy link
Member

@Forgind can you please pick up the investigation since you're kitten? Lower priority than 17.6 and 17.7-preview1 stuff.

dotnet-maestro bot and others added 2 commits May 1, 2023 12:38
…501.1

Microsoft.Net.Compilers.Toolset
 From Version 4.6.0-2.23171.5 -> To Version 4.7.0-2.23251.1
dotnet-maestro bot and others added 3 commits May 8, 2023 12:38
…505.2

Microsoft.Net.Compilers.Toolset
 From Version 4.6.0-2.23171.5 -> To Version 4.7.0-2.23255.2
…512.3

Microsoft.Net.Compilers.Toolset
 From Version 4.6.0-2.23171.5 -> To Version 4.7.0-2.23262.3
@ericstj
Copy link
Member

ericstj commented May 17, 2023

@steveharter noticed this locally and was sharing with @ViktorHofer.

I remember a similar version of this problem before
dotnet/runtime#59908
dotnet/sdk#22277

In that case it was due to torn state between roslyn assemblies. I wonder if that could be the cause here as well and somehow the preloading that we do didn't help.

@ViktorHofer
Copy link
Member

Here's a wild guess. This could be the result of the newly added Microsoft.Net.Compilers.Toolset.Framework nuget package. APICompat's target looks for the Microsoft.Net.Compilers.Toolset package only: https://github.com/dotnet/sdk/blob/838153aab0ab559f1a56c1de21f1967a9e37d1ac/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.ApiCompat.Common.targets#L23

Also, the use of Contains in that line seems wrong now with the newly added package.

@rainersigwald
Copy link
Member

This could be the result of the newly added Microsoft.Net.Compilers.Toolset.Framework nuget package.

I like the theory but I think it's not right, because the failing leg is "use Visual Studio 17.5 to build the repo in release mode with SDK 7.0.203" which shouldn't be aware of the .Framework package yet.

Also, the use of Contains in that line seems wrong now with the newly added package.

This still seems true though :)

@ViktorHofer
Copy link
Member

ViktorHofer commented May 17, 2023

I like the theory but I think it's not right, because the failing leg is "use Visual Studio 17.5 to build the repo in release mode with SDK 7.0.203" which shouldn't be aware of the .Framework package yet.

Yeah I just came to the same conclusion. Based on the binlog, the correct path is passed in to APICompat: D:\a\1\s\.packages\microsoft.net.compilers.toolset\4.7.0-2.23262.3\build\..\tasks\net472. That means that its probably the RoslynResolver that doesn't work anymore inside APICompat: https://github.com/dotnet/sdk/blob/838153aab0ab559f1a56c1de21f1967a9e37d1ac/src/ApiCompat/Microsoft.DotNet.ApiCompat.Shared/RoslynResolver.cs#L31-L34

My current guess is that before, the events were firing and resolving the assemblies from the custom path because the Task assembly had an assembly reference to the CodeAnalysis assemblies. With some refactoring this could have changed a few months ago so that its not ApiCompat.Task.dll that triggers the load of the Microsoft.CodeAnalysis assemblies but ApiCompatibility.dll which doesn't have the RoslynResolver enabled.

@rainersigwald
Copy link
Member

I think I understand this now. The problem is binding redirects on System.Collections.Immutable, kinda like this break from last year on System.Memory.

Specifically, MSBuild.exe.config (in 17.5) pulls references up to System.Collections.Immutable 6.0.0. That matches the Roslyn 4.6 dependency, so loading Roslyn up to 4.6 in the context of MSBuild 17.5 works great.

However, Roslyn 4.7 has moved to SCI 7.0.0.0 (as has MSBuild 17.6 but that's not relevant here because that AzDO machine definition is still on 17.6). That isn't automatically unified by the binding redirect (it's out of the range 0.0.0.0-6.0.0.0) so the loader finds it next to Roslyn:

Calling assembly : Microsoft.CodeAnalysis, Version=4.7.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35.
...
LOG: Assembly download was successful. Attempting setup of file: C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Current\Bin\amd64\System.Collections.Immutable.dll
LOG: Entering run-from-source setup phase.
LOG: Assembly Name is: System.Collections.Immutable, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
WRN: Comparing the assembly name resulted in the mismatch: Major Version
...
LOG: Attempting download of new URL file:///C:/.tools/.nuget/packages/microsoft.net.compilers.toolset/4.7.0-2.23262.3/tasks/net472/System.Collections.Immutable.DLL.
LOG: Assembly download was successful. Attempting setup of file: C:\.tools\.nuget\packages\microsoft.net.compilers.toolset\4.7.0-2.23262.3\tasks\net472\System.Collections.Immutable.dll
LOG: Entering run-from-source setup phase.
LOG: Assembly Name is: System.Collections.Immutable, Version=7.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
LOG: Where-ref bind Codebase does not match what is found in default context. Keep the result in LoadFrom context.
LOG: Binding succeeds. Returns assembly from C:\.tools\.nuget\packages\microsoft.net.compilers.toolset\4.7.0-2.23262.3\tasks\net472\System.Collections.Immutable.dll.
LOG: Assembly is loaded in LoadFrom load context.

However, the task references Microsoft.DotNet.ApiCompatibility, Version=7.0.203.0 which depends on System.Collections.Immutable, Version=5.0.0.0. That gets unified to 6.0.0.0 by the MSBuild.exe.config binding redirects to 6.0.0.0.

Then the failure is

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)

The mismatch is on System.Collections.Immutable.ImmutableArray`1<Byte>. The calling assembly is asking for a version-6 ImmutableArray but the implementing assembly has a version-7 ImmutableArray.

I think this is a problem that a user could run into for certain combinations of VS and SDK, but I don't know if it's a bug worth fixing, especially since VS 17.5 was STS and is now out of support. Our repo won't notice this problem in a couple of weeks after the build image is updated to VS 17.6, when MSBuild will binding redirect everything to 7 and unify again.

@ericstj
Copy link
Member

ericstj commented May 18, 2023

Makes sense. It’s a type agreement problem. We roll forward to latest Roslyn but don’t do so for its dependencies which overlap with ours (and the types we exchange with Roslyn). I wonder if we should add more assemblies to the set that gets loaded from Roslyn path?
https://github.com/dotnet/sdk/blob/10454f41ce95d767fb08e560a67da13ccba7c67d/src/ApiCompat/Microsoft.DotNet.ApiCompat.Shared/RoslynResolver.cs#L80

@rainersigwald
Copy link
Member

I think you might have to spin up an AppDomain to get that fully right, since MSBuild also uses SCI (but not on our public interface so having your own in the task that matches Roslyn would be fine). The loader was perfectly happy finding SCI 7 for Roslyn in the LoadFrom context, but it didn't do that when the task itself asked for SCI 5 since that was already satisfied.

@rainersigwald
Copy link
Member

@MichalPavlik to unblock this codeflow, I think we could switch the Windows Full Release (no bootstrap) build definition to use the dnceng windows.vs2022preview.amd64.open queue instead of the current hosted windows queue. Could you try that?

@ericstj
Copy link
Member

ericstj commented May 19, 2023

I think you might have to spin up an AppDomain to get that fully right, since MSBuild also uses SCI (but not on our public interface so having your own in the task that matches Roslyn would be fine). The loader was perfectly happy finding SCI 7 for Roslyn in the LoadFrom context, but it didn't do that when the task itself asked for SCI 5 since that was already satisfied.

We already do some manual loading. We've got two host/plugin releationships here. MSBuild is hosting the task and needs to unify all the types it talks to the task with. Luckily MSBuild controls this pretty well with a bindingRedirect hammer for it's own types and the framework unification for framework types (and is careful not to add more types to those interfaces). This task is the "host" for roslyn but we didn't take care to unify all the assemblies in Roslyn's public API -- only Roslyn itself. So we could look at all the assemblies that make up the public API and try to load those from the roslyn path.

…521.1

Microsoft.Net.Compilers.Toolset
 From Version 4.6.0-2.23171.5 -> To Version 4.7.0-2.23271.1
@rainersigwald
Copy link
Member

@MichalPavlik to unblock this codeflow, I think we could switch the Windows Full Release (no bootstrap) build definition to use the dnceng windows.vs2022preview.amd64.open queue instead of the current hosted windows queue. Could you try that?

Doing this in #8789.

rainersigwald added a commit that referenced this pull request May 23, 2023
Move (only) the `Windows Full Release (no bootstrap)` leg to the
`windows.vs2022preview.amd64.open` pool, which has Visual Studio 17.6 on
it already.

This will unblock #8674 by avoiding
dotnet/sdk#32691; the `MSBuild.exe.config`
binding redirects in the 17.6 VS will keep the current versions working
for the moment.
@rainersigwald rainersigwald enabled auto-merge (squash) May 23, 2023 20:00
@rainersigwald rainersigwald merged commit 7d65cb3 into main May 23, 2023
@rainersigwald rainersigwald deleted the darc-main-a0aec00d-d482-4e39-96c7-5aacd70aca5b branch May 23, 2023 20:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants