55

I'm trying to upgrade a .net core 2.1 project to the latest version of Nuget packages such as Microsoft.Extensions.DependencyInjection.Abstractions 2.1.1.

However this is blocked by the package reference Microsoft.NETCore.App, when I try to upgrade the "meta" package Microsoft.NETCore.App I see "Blocked by project" similar to this question. That was resolved by switching to the newer version of the SDK, however that isn't an option here... because there isn't a newer version of the SDK (yet?).

I've also seen this answer to upgrade specific packages by editing the .csproj file manually with an Update package reference but I doubt that's the intended method of doing this.

How should I go about this? For now I've just manually included the package references I actually use and dropped the meta package but I can't imagine that's the intended way to go about this.

5
  • 1
    Possible duplicate of Netcore 2.1.1 release leads to app failing to run Jun 21, 2018 at 14:01
  • 2
    Relevant: twitter.com/DamianEdwards/status/1009137684898435073 The whole blocked by project is by design. Asp.NET packages need the matching SDK to run correctly. Updating them oob is not an option.
    – imps
    Jun 21, 2018 at 19:03
  • Before doing this You might want to read the information in this > github.com/aspnet/AspNetCore/issues/9097#issuecomment-517922943
    – JimiSweden
    Aug 30, 2019 at 12:01
  • ... And section 4 from learn.microsoft.com/en-us/nuget/consume-packages/… (For some packages, the Update button is disabled and a message appears saying that it's "Implicitly referenced by an SDK" (or "AutoReferenced"). This message indicates that the package is part of a larger framework or SDK and should not be updated independently... This applies to the following commonly used packages: Microsoft.AspNetCore.All Microsoft.AspNetCore.App Microsoft.NETCore.App NETStandard.Library)
    – JimiSweden
    Aug 30, 2019 at 12:07
  • Your comments might be helpful but you might want to read the date this was posted at. Especially the year bit ;)
    – Elva
    Aug 30, 2019 at 13:15

9 Answers 9

42

Easy. Was looking for a resolution for this earlier and I all I had to do was just add this in the projects affected.

  <PropertyGroup>
    <RuntimeFrameworkVersion>2.1.1</RuntimeFrameworkVersion>
  </PropertyGroup>

Additionally for .NET Core 3 and beyond,

   <PropertyGroup>
     <TargetFramework>netcoreapp3.1</TargetFramework>
   </PropertyGroup>

There was also an answer posted by Patrick below pointing out that certain projects require the .NET Core App NuGet Package. You won't need that anymore after .NET Core 3.

6
  • 2
    This worked for me, however noticed that once you create new project, it does not contain mentioned configuration code. Thus still references 2.1.0 library instead of 2.1.1. Is this a bug in Visual Studio, as it shall target latest SDK installed?
    – Megrez7
    Jun 27, 2018 at 21:37
  • @Megrez7 Am actually facing that issue.. Will have report to you if I have some confirmation
    – Nicholas
    Jun 29, 2018 at 12:24
  • I have the 2.1.302 SDK installed and whilst this 'forces' the packages to the specified version, this seems like a bug to me as the projects should target the version of the SDK installed (like it actuals says in NuGet!?!) but this is clearly not happening
    – padigan
    Jul 19, 2018 at 13:26
  • And not forget that in .net 2.1 bootstrap's version is 3.7 and in .net 2.2 bootstrap version is 4.3 Apr 5, 2019 at 22:11
  • This fixed it for me with consolidating from 2.2.0 to 2.2.3.
    – Jay
    Apr 5, 2019 at 23:18
31

In my case it was caused by missing Version attribute on Microsoft.AspNetCore.App.

For some reason when the WebApi project was created the package was referenced like this:

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

Adding the missing attribute resolved all issues with updates and builds on the build server.

<PackageReference Include="Microsoft.AspNetCore.App" Version="2.1.1" />
2
  • 2
    I am not sure if this is the correct solution. Apparently, you can avoid setting the version and just install the latest SDK: stackoverflow.com/a/50977058/161640
    – Isaac
    Sep 16, 2018 at 16:51
  • @Isaac I've tried different solutions including installing SDKs and Runtimes manually, but nothing really worked except for setting explicit version of AspNetCore.App. Note that it is AspNetCore and not the NetCore. Also it could have been down to tooling - VS 2017 had couple of updates since then.
    – Patrick
    Sep 19, 2018 at 7:12
8

I had only Microsoft.NETCore.App 2.1.1 installed and couldn't update to Microsoft.NETCore.App 2.1.2 in Manage NuGet Packages... window because it showed "Blocked by project":

enter image description here

In the the image above it shows I'm on the latest version already because I did the following...

1 - download the latest version (v2.1.302 as of now) of .NET Core SDK here:

https://www.microsoft.com/net/download

2 - install it and run the following command in Visual Studio Package Manager Console or in Windows PowerShell. It should show the following:

PM> dotnet --info
.NET Core SDK (reflecting any global.json):
 Version:   2.1.302
 Commit:    9048955601

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

Host (useful for support):
  Version: 2.1.2
  Commit:  811c3ce6c0

.NET Core SDKs installed:
  1.0.0-rc4-004771 [C:\Program Files\dotnet\sdk]
  1.0.0 [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.2 [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.104 [C:\Program Files\dotnet\sdk]
  2.1.105 [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.300-preview2-008533 [C:\Program Files\dotnet\sdk]
  2.1.300-rc1-008673 [C:\Program Files\dotnet\sdk]
  2.1.300 [C:\Program Files\dotnet\sdk]
  2.1.301 [C:\Program Files\dotnet\sdk]
  2.1.302 [C:\Program Files\dotnet\sdk]

.NET Core runtimes installed:
  Microsoft.AspNetCore.All 2.1.0-preview2-final [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.All 2.1.0-rc1-final [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.All 2.1.0 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
  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.App 2.1.0-preview2-final [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 2.1.0-rc1-final [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 2.1.0 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  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.NETCore.App 1.0.3 [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.0 [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.0-preview2-26406-04 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.1.0-rc1 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.1.0 [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]

To install additional .NET Core runtimes or SDKs:
  https://aka.ms/dotnet-download
PM> 
2
  • This is the first part, the second part is to add the Version in the csproj file.
    – MC9000
    Mar 6, 2019 at 3:57
  • And not forget that in .net 2.1 bootstrap's version is 3.7 and in .net 2.2 bootstrap version is 4.3 Apr 5, 2019 at 22:11
7

Editing my .csproj file and adding the following line worked for me:

<PackageReference Include="Microsoft.NetCore.App" Version="2.1.1" />
6
  • I have been fighting the issue of not having 2.1 available for a new project for hours now. Decided to try to use this method. No luck. Here is the error: A PackageReference for 'Microsoft.NETCore.App' was included in your project. This package is implicitly referenced by the .NET SDK and you do not typically need to reference it from your project. For more information, see aka.ms/sdkimplicitrefs TipShare C:\Program Files\dotnet\sdk\2.1.201\Sdks\Microsoft.NET.Sdk\build\Microsoft.NET.Sdk.DefaultItems.targets 198 I tried this.
    – John
    Jun 24, 2018 at 22:24
  • 2
    Make sure you have the 2.1.1 runtime installed, in addition to the SDK. Run dotnet --info and you should see Microsoft.NETCore.App 2.1.1 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Jun 25, 2018 at 8:45
  • If you hae the 2.1.1 runtime installed, this works, and is, to my knowledge, the only way to get it to work (today). Folks should verify info before down voting.
    – TadGhostal
    Jun 27, 2018 at 21:50
  • I agree, this works and is (or should really be) required in addition to the answer by Nicholas above...
    – padigan
    Jul 19, 2018 at 13:26
  • And not forget that in .net 2.1 bootstrap's version is 3.7 and in .net 2.2 bootstrap version is 4.3 Apr 5, 2019 at 22:11
1

In my case, @Patrick's answer is correct. At least for VS 2017 (15.8.9) with SDK file "dotnet-sdk-2.1.403-win-x64.exe" installed.

Symptoms: Creating a new Web project sets the Aspnetcore.App version to 2.1 even though the latest SDK is installed. Attempting to change the version via the NuGet Manager responds with 'project blocked'.

Resolution: Add Version="2.1" to the reference in CSPROJ like this:

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

After save/reopen, the NuGet manager will allow selecting other versions of the SDK. Note that adding Version="2.1.5" directly then saving the CSProj file should trigger the upgrade/restore automatically.

Thanks @Patrick

0

For me, I had the following line twice in the csproj file

<PackageReference Include="Microsoft.AspNetCore.StaticFiles " Version="2.2.0" />

Simply removing the duplicate resolved the issue

0

You can install using the Package Manager Console with the command. for an example:

Install-Package Microsoft.AspNetCore.App -Version 2.2.8

-1
  1. Right click on your project
  2. Click on "Properties"
  3. Change "Target Framework" accordingly
  4. Save and close the properties window. This will resolve issue auto, else you can go to Nuget and upgrade the assemblies by yourself.
1
  • 1
    Target framework is netcoreapp2.0, netcoreapp2.1, netcoreapp2.2 but here we discuss about fix version, so your proposition is not applicable for solution. Nov 21, 2019 at 17:15
-2

As @Simon_Weaver said this happens when no version specified and 2.1.301 SDK is not present in a system

2
  • 1
    This is not true for me at least, I have the 2.1.302 SDK installed and when creating new projects they work fine and in nuget the Microsoft.NetCore.App says 2.1.2 - however in existing projects created before 2.1.302 was installed I have this problem.
    – padigan
    Jul 19, 2018 at 13:21
  • Each package version corresponds to its SDK version. 2.1.0 - > 2.1.300 2.1.1 - > 2.1.301 2.1.2 - > 2.1.302
    – XperiAndri
    Aug 5, 2018 at 19:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.