I opened my Visual Studio 2022 project this morning and cannot get it to run any more due to the following error:
CS9057 The analyzer assembly 'C:\Program Files\dotnet\sdk\8.0.100-preview.6.23330.14\Sdks\Microsoft.NET.Sdk.Razor\source-generators\Microsoft.NET.Sdk.Razor.SourceGenerators.dll' references version '4.7.0.0' of the compiler, which is newer than the currently running version '4.6.0.0'."
I am currently using Microsoft Visual Studio Community 2022 (64-bit) Version 17.6.5
My project file:
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Components.Analyzers" Version="6.0.20" />
<PackageReference Include="Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore" Version="6.0.16" />
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="6.0.16" />
<PackageReference Include="Microsoft.AspNetCore.Identity.UI" Version="6.0.16" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Analyzers" Version="6.0.20" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="6.0.16" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="6.0.16" />
<PackageReference Include="MudBlazor" Version="6.2.3" />
</ItemGroup>
</Project>
I did recently install the Microsoft Visual Studio Community 2022 (64-bit) Version 17.7.0 Preview 3.0
that includes the .NET 8 SDK
. This is what seems to be causing the analyzer reference conflict.
I have not been able to find documentation to aid me in changing my analyzer references back to the correct version and there does not seem to be any way to do it in the Nuget Package Manager
or the Reference Manager
.
My other .NET 6 projects work, just not this one.
I have tried cleaning the project and deleting the obj and bin folders and even deleting the vs folder.
output from dotnet --list-sdks
:
3.0.103 [C:\Program Files\dotnet\sdk] 3.1.426 [C:\Program Files\dotnet\sdk] 7.0.306 [C:\Program Files\dotnet\sdk] 7.0.400-preview.23330.10 [C:\Program Files\dotnet\sdk] 8.0.100-preview.6.23330.14 [C:\Program Files\dotnet\sdk]
Output from dotnet --version
:
8.0.100-preview.6.23330.14
How do I change the analyzer references back to .NET 6? or what is the best way to fix this problem?