Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Re-target .NET Core to net471, net 472

My .Netcore 2.0 project can target net471. But when I upgraded to .NET 2.1, I can't retarget net471 or net472

Can I retarget in the latest version of .the NET core?

Severity Code Description Project File Line Suppression State
Error NU1202 Package Microsoft.AspNetCore.App 2.1.0 is not compatible with net471 (.NETFramework,Version=v4.7.1). Package Microsoft.AspNetCore.App 2.1.0 supports: netcoreapp2.1 (.NETCoreApp,Version=v2.1) 

and

Severity Code Description Project File Line Suppression State
Error NU1202 Package Microsoft.AspNetCore.App 2.1.0 is not compatible with net472 (.NETFramework,Version=v4.7.2). Package Microsoft.AspNetCore.App 2.1.0 supports: netcoreapp2.1 (.NETCoreApp,Version=v2.1) 
like image 378
Hung Quach Avatar asked Jun 19 '18 04:06

Hung Quach


People also ask

Can we change .NET Core to .NET framework?

NET Core to . NET Framework. That's possible with target monikers by changing netcoreapp1. 0 to net462 or net451 or alike.

How do I change my target framework to .NET 6?

To set target . NET runtime version to 6.0, enter <TargetFramework>net6. 0</TargetFramework> version in project's . csproj file directly.


1 Answers

It looks like Microsoft.AspNetCore.App and Microsoft.AspNetCore.All packages only work with the netcoreapp2.0 or netcoreapp2.1 version.

Wanting to target .NET Framework i.e. net471, net472, you have to remove these packages and manually add the references.

In my case, I removed Microsoft.AspNetCore.App and added references as below.

<PackageReference Include="Microsoft.AspNetCore" Version="2.1.1" />
<PackageReference Include="Microsoft.AspNetCore.Hosting.WindowsServices" Version="2.1.1" />
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="2.1.1" />
<PackageReference Include="Microsoft.AspNetCore.StaticFiles" Version="2.1.1" />
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="2.1.1" />
<PackageReference Include="Microsoft.Extensions.Logging.EventLog" Version="2.1.1" />
<PackageReference Include="Microsoft.Extensions.Options" Version="2.1.1" />
like image 161
Hung Quach Avatar answered Sep 20 '22 21:09

Hung Quach