Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I migrate from ASP.NET Core 2.1 to 2.2 easily?

I have a project which made by asp.net core 2.1, and now I wanna to migrate to the 2.2 version.

I installed the SDK of 2.2 and changed the target framework to 2.2 in properties of the project.

After I clean&rebuild the solution, there are some warnings here I can not clean it:
1. enter image description here

2. enter image description here

3. enter image description here

I found a tutorial about this which provided by Microsoft: https://docs.microsoft.com/en-us/aspnet/core/migration/21-to-22?view=aspnetcore-2.2&tabs=visual-studio

I tried but still no work.

I think updating the new version SDK is easier like the .net framework by just changes the target framework in properties of the project. However, it seems not.

I wonder if there have an official tool which to update the .net core SDK from 2.1 to 2.2. Or I'd better create a brand new 2.2 project as well as paste all the file into it rather than fix the troublesome warnings.

Thank you.

like image 314
102425074 Avatar asked Dec 06 '18 22:12

102425074


People also ask

How can I update my NET Core 2.1 to .NET 6?

Upgrading packages If you're using Visual Studio (or Rider), right-click on your Solution and click Manage nuget packages . Specifically, we're interested in packages which have an update available.

Is .NET Core 2.1 still supported?

NET Core 2.1 will be reaching end of support on August 21, 2021 and after this date we will no longer provide updates including security fixes, or technical support for this version. We strongly recommend you migrate your applications to . NET Core 3.1 or later before this date.


3 Answers

Finally, I used the most stupid way that creates a brand new empty .net core 2.2 project and pastes most of the old project file(including the model/controllers/view/stylesheet/javascript but except the csproj/Properties)to it.

Then clear the solution and rebuild, all warning clear.

This way is so rude and unprofessional, but maybe is the easiest way to do it.

like image 125
102425074 Avatar answered Oct 06 '22 01:10

102425074


Okay, so I found an easier solution than to renew the entire project. What I did was

Made sure those two lines exist in my project file.

 <PropertyGroup>
    <TargetFramework>netcoreapp2.2</TargetFramework>
    <RuntimeFrameworkVersion>2.2.0</RuntimeFrameworkVersion>
  </PropertyGroup>

Then I had errors saying that some of the packages were not compatible, so I changed the versions of those as well. It was those two specifically:

 <ItemGroup>
    <PackageReference Include="Microsoft.AspNetCore.Razor.Design" Version="2.2.0" PrivateAssets="All" />
    <PackageReference Include="Microsoft.AspNetCore.SpaServices.Extensions" Version="2.2.0" />
  </ItemGroup>

After that everything compiled successfully without warnings.

like image 24
merlinabarzda Avatar answered Oct 06 '22 01:10

merlinabarzda


The schema errors may be an indicator that you are using an outdated Visual Studio 2017 edition.

To use .NET Core 2.2 you need to update to the latest Visual Studio 2017.9 (15.9).

Prerequisites for .NET Core on Windows:

To verify your Visual Studio version:

  • On the Help menu, choose About Microsoft Visual Studio.
  • In the About Microsoft Visual Studio dialog, verify the version number.
    • For .NET Core 3.0 Preview 1 apps, Visual Studio 2019 Preview 1 or higher.
    • For .NET Core 2.2 apps, Visual Studio 2017 version 15.9 or higher.
    • For .NET Core 2.1 apps, Visual Studio 2017 version 15.7 or higher.
    • For .NET Core 1.x apps, Visual Studio 2017 version 15.0 or higher.
like image 33
Tseng Avatar answered Oct 06 '22 01:10

Tseng