-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Description
When customers build with msbuild they get the compiler that comes with the Visual Studio but many of the tasks and targets that ship with the chosen .NET SDK. Practically speaking that means analyzers / generators come from the .NET SDK install but the compiler that runs them comes from Visual Studio.
This can lead to problems when the version of .NET SDK is newer than MSBuild. That opens up the potential for analyzers / generators to exist that depend on a newer version of the Roslyn compiler than exists in MSBuild. When that happens customers will get errors like the following:
CSC : warning CS9057: The analyzer assembly '..\dotnet\sdk\8.0.200\Sdks\Microsoft.NET.Sdk.Razor\source-
generators\Microsoft.CodeAnalysis.Razor.Compiler.SourceGenerators.dll' references version '4.9.0.0' of the compiler, which is newer
than the currently running version '4.8.0.0'. To fix this issue we're going to change the workflow here such that MSBuild will use the same compiler as the .NET SDK when the .NET SDK is newer than the running MSBuild. There are several pieces involved in getting this working:
- Roslyn will produce a NuPkg that overrides the compiler in MSBuild (Framework compilers package for SDK consumption #66206)
- .NET SDK will respect a new property called
BuildWithNetFrameworkHostedCompilerthat installs this NuPkg (Add PackageReference to new Roslyn package (#29787) sdk#32734) - MSBuild will produce a property that is true when there is a MSBuild / .NET SDK mismatch. (Generate a props file that can be used to detect MSBuild version mismatches installer#19144) 8.0.3xx backport
- Roslyn will follow the F# pattern for getting the NuPkg published as part of the SDK publish story: part 1 and part 2. (Publish Roslyn Framework Toolset package as part of SDK sdk#39743)
- MSBuild will make a change such that
BuildWithNetFrameworkHostedCompileris true whenever it detects a MSBuild / .NET SDK mismatch. (Ingest new props file from installer and use it to auto-include Toolset Compilers package sdk#39701) -
dotnet build-server shutdownwill update such that it can shut down compilers from this NuPkg. - Update our test passes to include validating these scenarios are working
- Change arcade to have
BuildWithNetFrameworkHostedCompilerset totrueby default.
Note: in this issue the term msbuild or MSBuild refers to the .NET Framework MSBuild installed with Visual Studio, not dotnet msbuild.