Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to update AspNetCore from 2.2.0 to 2.2.2

tldnr: How do I upgrade Microsoft.AspNetCore.App from 2.2.0 to 2.2.2? It's disabled in the package manager UI.


When I created a testproject I realized that Microsoft.AspNetCore.App was version 2.2.2 (newest version) whereas in my main Api project it was 2.2.0.

projects dependencies and SDK references

I could not update it due to

Implicitly referenced by an SDK. To update the package, update the SDK to which it belongs

nuget manager blocking update of package to 2.2.2

I do have SDK 2.2.104 installed, which should contain 2.2.2 (I love how straight forward Microsoft is with its version numbers)

C:\Users\matthias>dotnet --list-sdks
2.1.202 [C:\Program Files\dotnet\sdk]
2.1.402 [C:\Program Files\dotnet\sdk]
2.1.403 [C:\Program Files\dotnet\sdk]
2.1.503 [C:\Program Files\dotnet\sdk]
2.1.504 [C:\Program Files\dotnet\sdk]
2.1.600-preview-009472 [C:\Program Files\dotnet\sdk]
2.2.104 [C:\Program Files\dotnet\sdk]

What's the correct way of updating this all to 2.2.2? I could set the version number for the package in the csproj and it seems to work just fine, but I guess that's not the clean way to go. Why would the UI disable it then.

Project file is from the default template.

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

  <PropertyGroup>
    <TargetFramework>netcoreapp2.2</TargetFramework>
    <AspNetCoreHostingModel>InProcess</AspNetCoreHostingModel>
  </PropertyGroup>

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

</Project>

Source: https://github.com/matthiaslischka/netcore222updateissue

UPDATE:

I have now added RuntimeFrameworkVersion 2.2.2 to the csproj like ESG suggested and now I get this strange view:

Nuget manager shows different versions for the same package

I've inspected the compiled DLLs with ILSpy and it seems to still be 2.2.0.0 ilspy show version 2.2.0.0

like image 869
Matthias Avatar asked Feb 23 '19 14:02

Matthias


2 Answers

I posted this in response to Andy's GitHub bug, but re-posting it here for further reach:

If you are using .NET Core, the only thing you need to do to update to the patch is install the latest patched runtime on the machine running the app (i.e. your servers, dev boxes, etc.).

.NET Core applications automatically roll forward to the highest patch version associated with the major/minor pair you target. This behavior can be disabled using a setting in [appname].runtimeconfig.json but we strongly recommend you keep it to ensure you always run on the most up-to-date runtime (with all released security fixes).

While we do recommend you run on the latest patch, we recommend you do not update your app to target later patch versions as your app will fail to start if that patch doesn't exist on the target machine. Patches shouldn't be introducing APIs that you need to update to depend upon so there's no need to update the package reference.

like image 179
Andrew Stanton-Nurse Avatar answered Oct 25 '22 01:10

Andrew Stanton-Nurse


Since you have the 2.2.2 .Net core SDK, you force the version of ASP.Net by specifying the RuntimeFrameworkVersion in your csproj.

<PropertyGroup>
    <RuntimeFrameworkVersion>2.2.2</RuntimeFrameworkVersion>
</PropertyGroup>
like image 44
ESG Avatar answered Oct 25 '22 01:10

ESG