I'm trying to build an ASP.NET-Core 3.1
(netcoreapp3.1
) application which has a dependency on a NuGet library that is .NET-Standard 2.0
which uses MSBuild SDK "Microsoft.NET.Sdk.Razor"
.
This builds and runs fine from Visual Studio (2019) but when I run dotnet build
I get the following error:
Build FAILED.
CSC : error CS8034: Unable to load Analyzer assembly
C:\Users\daniel\.nuget\packages\microsoft.aspnetcore.mvc.analyzers\2.2.0\analyzers\dotnet\cs\Microsoft.AspNetCore.Mvc.Analyzers.dll
: Assembly with same name is already loaded [D:\git\myapp\src\myapp.App\myapp.App.csproj]
0 Warning(s)
1 Error(s)
My guess is that my .NET-Standard 2.0
library is pulling in Microsoft.CodeQuality.Analyzers
2.x via the Microsoft.NET.Sdk.Razor
SDK and this conflicts with the one being pulled in by the ASP.NET-Core 3.1
application.
Is there either a way to build my application via command line in the same way Visual Studio does it?
Is the proper solution to use multi-targeting and #if NETCOREAPP3_1
blocks in my library?
NET Core 3.1 was originally released on December 3, 2019 and is supported for three years. But the actual end of support day will be the closest Patch Tuesday starting that date, which is December 13, 2022.
NET Core vs ASP.NET Core. . NET Core is a runtime to execute applications build on it. ASP.NET Core is a web framework to build web apps, IoT apps, and mobile backends on the top of .
NET Core is an implementation of the . NET Standard that's optimized for building console applications, Web apps and cloud services using ASP.NET Core. Its SDK comes with a powerful tooling that in addition to Visual Studio development supports a full command line-based development workflow.
Microsoft released . NET Core 3.1 in December 2019, and it is a long-term supported (LTS) release, which explains why it's getting three years of support.
This is a workaround to hide the annoying message, but it will not actually remove the underlying issue:
Edit the .csproj and add a 8034 (CS8034) <NoWarn>
to the Configuration/Platform <PropertyGroup>
like this:
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<!-- ... -->
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<NoWarn>8034</NoWarn>
</PropertyGroup>
<!-- ... -->
</Project>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With