问题
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.
回答1:
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>
回答2:
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" />
回答3:
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":
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>
回答4:
Editing my .csproj file and adding the following line worked for me:
<PackageReference Include="Microsoft.NetCore.App" Version="2.1.1" />
回答5:
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
回答6:
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
回答7:
- Right click on your project
- Click on "Properties"
- Change "Target Framework" accordingly
- Save and close the properties window. This will resolve issue auto, else you can go to Nuget and upgrade the assemblies by yourself.
回答8:
As @Simon_Weaver said this happens when no version specified and 2.1.301 SDK is not present in a system
来源:https://stackoverflow.com/questions/50970211/microsoft-aspnetcore-app-2-1-1-upgrade-blocked-by-project