11

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://learn.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.

102425074
  • 781
  • 1
  • 7
  • 23
  • https://stackoverflow.com/questions/50970211/microsoft-aspnetcore-app-2-1-1-upgrade-blocked-by-project might be what you are looking for. As of this writing https://aka.ms/dotnet-download is also helpful to get to the latest. – No Refunds No Returns Dec 06 '18 at 22:26
  • Do you have the latest visual studio update installed? 15.9.3 as of the time of writing. iirc you need 15.9 to for .NET Core 2.2. Also do not post errors/warnings as images, include them as text. People are not going to type that when they search it on google :P – Tseng Dec 06 '18 at 23:07
  • @NoRefundsNoReturns Thanks for providing these ways, I tried but no works. – 102425074 Dec 07 '18 at 01:25
  • The first one is just recommending not to use version for that assembly - you can just edit .`csproj` to remove the version. The other 2 are coming from your publish profile - have you updated version in that also? – James P Dec 07 '18 at 02:43
  • @JamesP I updated the version yet, but I don't know why Visual Studio still reports this. – 102425074 Dec 07 '18 at 03:24
  • I think i should install authorization packages because it does not find them. And also **Webhost** in the **program.cs** not found!!! – Armin Torkashvand Jan 01 '19 at 08:23
  • And not forget that in .net 2.1 bootstrap's version is 3.7 and in .net 2.2 bootstrap version is 4.3 – Diego Venâncio Apr 05 '19 at 22:10

3 Answers3

17

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.

merlinabarzda
  • 668
  • 5
  • 15
  • 9
    You also need to update the compatibility version in `Startup.ConfigureServices` to Version_2_2: `services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2);`. also, to use the faster in-process hosting model for IIS, add `InProcess` to your .csproj file after `netcoreapp2.2` – S.Serpooshan Feb 16 '19 at 06:42
  • And not forget that in .net 2.1 bootstrap's version is 3.7 and in .net 2.2 bootstrap version is 4.3 – Diego Venâncio Apr 05 '19 at 22:10
  • @DiegoVenâncio I haven't used the bootstrap yet. However, thank you all the same. – 102425074 Apr 06 '19 at 02:46
5

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.

102425074
  • 781
  • 1
  • 7
  • 23
  • If things get complicated, I would also use this method. Also makes you do some code cleaning. – Umair Jul 10 '19 at 10:26
  • I just tried upgrading from 2.1 to 3.1 (through 2.2 and then 3.0), and after wasting about two hours doing it the "right" way, I spent about 15 minutes just creating a brand new project. – tp803 Apr 29 '20 at 15:39
3

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.
Tseng
  • 61,549
  • 15
  • 193
  • 205
  • 1
    My visual studio 2017 version is 15.9.3. And I just installed the 2019 preview also. But even I use the 2019, the problem still here. – 102425074 Dec 07 '18 at 01:07