Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Upgrading from ASP.NET Core 2.2 to 3.0

I have an ASP.NET Core project with following csproj configuration:

<PropertyGroup>   <TargetFramework>netcoreapp2.2</TargetFramework> </PropertyGroup> <ItemGroup>   <PackageReference Include="Microsoft.AspNetCore.App" /> </ItemGroup> 

I want to upgrade the project to <TargetFramework>netcoreapp3.0</TargetFramework>. Upon doing so, however, I get following warning:

C:\Program Files\dotnet\sdk\3.0.100\Sdks\Microsoft.NET.Sdk\targets\ Microsoft.NET.Sdk.DefaultItems.targets(149,5): warning NETSDK1080: A PackageReference to Microsoft.AspNetCore.App is not necessary when targeting .NET Core 3.0 or higher. If Microsoft.NET.Sdk.Web is used, the shared framework will be referenced automatically. Otherwise, the PackageReference should be replaced with a FrameworkReference.

What precisely is the solution to this? I tried to remove reference to Microsoft.AspNetCore.App, but that does not work. The code does not reference the shared framework.

Also, what does "Otherwise, the PackageReference should be replaced with a FrameworkReference" mean?

like image 882
Abhi Avatar asked Sep 30 '19 08:09

Abhi


People also ask

What is new in core 3.0 in asp net?

Performance improvements ASP.NET Core 3.0 includes many improvements that reduce memory usage and improve throughput: Reduction in memory usage when using the built-in dependency injection container for scoped services. Reduction in allocations across the framework, including middleware scenarios and routing.

Is Asp.Net Core deprecated?

NET Framework will be deprecated. This means you can only use . NET Framework as long as your operating systems (for example Windows Server 2019) still supports it. And with Microsoft shortening its support lifecycles, your operating system end-of-life will come sooner than you may think.

Is .NET Core 3.1 backwards compatible?

NET Core 3.1, as it's backwards compatible with .


1 Answers

If you are building a web project, please make sure the first line of your project file is:

<Project Sdk="Microsoft.NET.Sdk.Web"> 

In this case, it is automaticly included framework: Microsoft.AspNetCore.App. You don't have to include it again.

https://docs.microsoft.com/en-us/aspnet/core/migration/22-to-30?view=aspnetcore-3.0&tabs=visual-studio#framework-reference

If you are building a razor library not a web project, please make sure the first line of your project file is:

<Project Sdk="Microsoft.NET.Sdk.Razor"> 

In this case, your library might dependend on some class in ASP.NET Core. You have to add this:

  <ItemGroup>      <FrameworkReference Include="Microsoft.AspNetCore.App" />   </ItemGroup> 

Don't forget to add:

    <AddRazorSupportForMvc>true</AddRazorSupportForMvc> 

to <PropertyGroup>

If you are not building a razor library nor a web project, typically you don't need Microsoft.AspNetCore.App. If you can really make sure what you are doing and really need it , consider adding:

  <ItemGroup>      <FrameworkReference Include="Microsoft.AspNetCore.App" />   </ItemGroup> 
like image 180
Anduin Avatar answered Sep 19 '22 04:09

Anduin