Aspnetcore: Installing SDK 2.2.1 but no way to update SDK Dependencies from 2.2.0 to 2.2.1

Created on 25 Jan 2019  Â·  15Comments  Â·  Source: dotnet/aspnetcore

I have SDK 2.2.0, and installed SDK 2.2.103

Now I expected to see or find a way to update the SDK dependencies from version 2.2.0 to 2.2.1, but can't find a way to make this happen.

bug?

image

Duplicate area-platform

All 15 comments

I have to manually edit the csproj file to change this:

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

to

<PackageReference Include="Microsoft.AspNetCore.App" Version="2.2.1" />

@wstaelens this is no longer a recommended approach to set the version to the Microsoft.AspNetCore.App. On my side, I control everything using the global.json. This is the one enforcing the proper SDK.
Hope this helps!
JS

@masterjs I cannot find a "global.json" in my solution or folder?

@wstaelens you should read up on it a little bit, its very useful. (https://docs.microsoft.com/en-us/dotnet/core/tools/global-json)
Its not there by default. Add it to the level you desire (I usually put it at the solution level to affect all my aspnetcore projects). It basically enforce that you project will ONLY work with a specific version. Mine has for instance the following:
{ "sdk": { "version": "2.2.100" } }
This mean that my build server and any other dev from the team NEED the SDK version 2.2.100 installed.

thank you,
JS

ok I can follow, but when not using a global.json. How can I ensure the latest version of Microsoft.AspNetCore.App is used from the latest installed SDK?

Like in my case I had SDK 2.2.0, downloaded and installed SDK 2.2.1 but the Microsoft.AspNetCore.App stayed at 2.2.0. Only thing I could do is add a specific version.

Without adding a global.json, is this a bug or is there another solution to not specifying the version number and still using the latest version?

Open a dev command line and run dotnet --info . This will tell you the current version of the you're using for real. If you dont have a global.json, your project will usually use the latest SDK version installed on your machine for the 2.2.x version.

@wstaelens I also just found this documentation on the MS site that exactly explain how its is "implicitly" getting the right version: https://docs.microsoft.com/en-us/aspnet/core/fundamentals/metapackage-app?view=aspnetcore-2.2

this should answer all your questions!
JS

@masterjs thanks for the info.

... so after installing the latest SDK, I would expected that version 2.2.1 of the Microsoft.AspNetCore.App package would be used (by looking at the SDK Dependencies in the Solution Explorer) if I read that last link. This was not the case. Version 2.2.0 was still being used after installing 2.2.1 and restarting Visual Studio. That is why I've unloaded my project and added a version number manually. Strange… or at least very confusing!
I'll go with the global.json that you provided. I'm sure others will find this topic interesting if I see the number of questions on stackoverflow.

@natemcmaster - any further thoughts on this?

any further thoughts on this?

...only that this further justifies why we're refactoring this experience in 3.0. cref https://github.com/aspnet/AspNetCore/issues/3612

The previous commenters are correct - you do not need to add the version attribute to the PackageReference. Just installing the latest .NET Core SDK or Runtime installers is enough to get 2.2.1. See https://natemcmaster.com/blog/2018/08/29/netcore-primitives-2/ if you want to read more details on this subject.

Closing as a duplicate of https://github.com/dotnet/project-system/issues/3791.

@masterjs @natemcmaster @Eilon ok i've removed the version from the csproj file. added a json file called "global.json" with this info:

{
  "sdk": {
    "version": "2.2.103"
  }
}

and my SDK dependencies still show Microsoft.AspNetCore.App (2.2.0) instead of 2.2.1.

dotnet --info
.NET Core SDK (reflecting any global.json):
 Version:   2.2.103
 Commit:    8edbc2570a

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.17763
 OS Platform: Windows
 RID:         win10-x64
 Base Path:   C:\Program Files\dotnet\sdk\2.2.103\

Host (useful for support):
  Version: 2.2.1
  Commit:  878dd11e62

.NET Core SDKs installed:
  1.0.0-preview1-002702 [C:\Program Files\dotnet\sdk]
  1.0.0-preview2-003121 [C:\Program Files\dotnet\sdk]
  1.0.0-preview2-003131 [C:\Program Files\dotnet\sdk]
  1.0.3 [C:\Program Files\dotnet\sdk]
  1.0.4 [C:\Program Files\dotnet\sdk]
  1.1.0 [C:\Program Files\dotnet\sdk]
  2.0.0 [C:\Program Files\dotnet\sdk]
  2.0.2 [C:\Program Files\dotnet\sdk]
  2.0.3 [C:\Program Files\dotnet\sdk]
  2.1.2 [C:\Program Files\dotnet\sdk]
  2.1.4 [C:\Program Files\dotnet\sdk]
  2.1.100 [C:\Program Files\dotnet\sdk]
  2.1.101 [C:\Program Files\dotnet\sdk]
  2.1.102 [C:\Program Files\dotnet\sdk]
  2.1.103 [C:\Program Files\dotnet\sdk]
  2.1.104 [C:\Program Files\dotnet\sdk]
  2.1.200 [C:\Program Files\dotnet\sdk]
  2.1.201 [C:\Program Files\dotnet\sdk]
  2.1.202 [C:\Program Files\dotnet\sdk]
  2.1.301 [C:\Program Files\dotnet\sdk]
  2.1.400 [C:\Program Files\dotnet\sdk]
  2.1.401 [C:\Program Files\dotnet\sdk]
  2.1.402 [C:\Program Files\dotnet\sdk]
  2.1.403 [C:\Program Files\dotnet\sdk]
  2.1.500 [C:\Program Files\dotnet\sdk]
  2.1.502 [C:\Program Files\dotnet\sdk]
  2.1.503 [C:\Program Files\dotnet\sdk]
  2.2.101 [C:\Program Files\dotnet\sdk]
  2.2.102 [C:\Program Files\dotnet\sdk]
  2.2.103 [C:\Program Files\dotnet\sdk]

.NET Core runtimes installed:
  Microsoft.AspNetCore.All 2.1.1 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.All 2.1.2 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.All 2.1.3 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.All 2.1.4 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.All 2.1.5 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.All 2.1.6 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.All 2.1.7 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.All 2.2.0 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.All 2.2.1 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.App 2.1.1 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 2.1.2 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 2.1.3 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 2.1.4 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 2.1.5 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 2.1.6 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 2.1.7 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 2.2.0 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 2.2.1 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 1.0.0-rc2-3002702 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 1.0.0 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 1.0.1 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 1.0.4 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 1.0.5 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 1.1.1 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 1.1.2 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.0.0 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.0.3 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.0.5 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.0.6 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.0.7 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.0.9 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.1.1 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.1.2 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.1.3 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.1.4 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.1.5 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.1.6 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.1.7 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.2.0 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.2.1 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]

To install additional .NET Core runtimes or SDKs:
  https://aka.ms/dotnet-download

C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional>

(i tried version numbes 2.2.100, 2.2.1, etc...)
😞

@natemcmaster you closed it, but tell me. I'm still stuck at 2.2.0 now for the Microsoft.AspNetCore.App package.

When i edit the project file and add a version number to it, it is ok, but not recommended, so I removed it again.

I've added a json file called global.json as suggested and added the specific sdk version, but the Microsoft.AspNetCore.App is still at 2.2.0 instead of 2.2.1.
Nuget packages can't be updated as they are "blocked".
So how do I now update the Microsoft.AspNetCore.App SDK dependency from 2.2.0 to 2.2.1 without specifying a version number behind the package, while having the latest SDK installed AND with a global.json file.

@masterjs ?

So how do I now update the Microsoft.AspNetCore.App SDK dependency from 2.2.0 to 2.2.1 without specifying a version number behind the package

You don't need to reference the higher package. I referenced https://github.com/dotnet/project-system/issues/3791 because the UI is misleading. If you have installed the 2.2.1 runtime, your application will automatically rollforward to use it. By default, .NET Core always runs on the highest patch installed on the machine, 2.2.* in your case because you target 'netcoreapp2.2'.

I know this is confusing and breaks the traditional usage of a PackageReference, which is why in .NET Core 3.0, we will no longer be using NuGet to distribute the Microsoft.AspNetCore.App reference. See https://github.com/aspnet/AspNetCore/issues/3307 and https://github.com/aspnet/AspNetCore/issues/3612 if you want more details on this subject.

So Visual Studio does not know I'm using sdk 2.2.103 because it shows package 2.2.0 instead of 2.2.1 ?
but still it knows it can't use package 2.2.1 because it is blocked.

very confusing I must say. (and I did not add these nuget packages, can't uninstall or update them).

image

The primary purpose of these 'SDK' package references is to provide the C# compiler with "reference assemblies" (sort of like headers in C#). Unlike most normal packages, Microsoft.AspNetCore.App and Microsoft.NETCore.App do not put more *.dll files in your build output. If you run dotnet publish, you won't see any Microsoft.AspNetCore.*.dll or System.*.dll files in your output. When your application runs, it will find those files in the .NET Core installation (typically in C:\Program Files\dotnet\).

Because of this, the package version is always going to stay at '2.2.0', regardless of which SDK you are using. We don't add new .NET Core APIs in patch releases, and by targeting the 2.2.0 reference, your application will remain compatible with any machine that has .NET Core 2.2 installed. he reason upgrade is blocked from the UI is that it often has unintended consequences. Most users do not need to change this version.

If you would like to read more details on how this works, here are some docs and a blog post I wrote explaining these concepts.

Was this page helpful?
0 / 5 - 0 ratings