ChatGPT解决这个技术问题 Extra ChatGPT

Visual Studio 2017 cannot update Microsoft.NETCore.App package ("Blocked by project")

https://i.stack.imgur.com/bOqUI.png

https://i.stack.imgur.com/XqkkI.png

https://i.stack.imgur.com/cbxqp.png

Looks like the test project is blocking the downgrade. Did you try to right click on the solution and select manage nuget packages for the solution and move all the projects to the different version at the same time?
I hadn't thought of that but I just tried it and I get that same "Blocked by project" error. Also the other project is blocked from moving away from 1.1.2. I also installed the latest update for VS but that didn't help.
I´ve collected all information I found in this question/answer: stackoverflow.com/questions/52518059/… because this problem seems to be really a question. The answers here are not complete for my scenario
Had the same error when I was mistakenly targeting different versions of the .net core framework across different projects in my solution. Make sure the project properties for each target the same version.

M
Martin Ullrich

EDIT 2018: Only follow the instructions for updating the package if you really know what you are doing. In most cases, you never need to update this package - or other packages marked as "blocked by project" - manually. A framework-dependent app will use the latest runtime available and a self-contained application will perform an extra build using a newer version of this package automatically. (there are some edge cases where you need to upgrade this package in test projects. in this case, add <TargetLatestRuntimePatch>true</…> and see this Q&A for other options)

The implicit package references that the Microsoft.NET.Sdk infers can't be updated via NuGet.

If you migrated from project.json, the project with the 1.1.0 reference likely contains

<RuntimeFrameworkVersion>1.1.0</RuntimeFrameworkVersion>

in the csproj file or an item like this (if you may used the package manager previously to set the version):

<PackageReference Update="Microsoft.NETCore.App" Version="1.1.0" />

Delete entries like the above and all packages will reference 1.1.2 (or whatever the installed SDK considers to be the latest) automatically. Alernatively, set RuntimeFrameworkVersion in all projects.


You were right: I opened the .csproj file and removed the <RuntimeFrameworkVersion>1.1.0</RuntimeFrameworkVersion> line. VS still won't let me manually change the version but at least it's the right version now (it updated to 1.1.2 like you said it would)
M
Marlon Dias

I had similar problem trying to install Entityframework.Core package in a .NET Core 2 Web app. To solve the issue, I've forced installation through Package Manager Console:

Install-Package Microsoft.NETCore.App -Version 2.0.5

(2.0.5 was the most recent version at the time)

I hope it's useful. Peace.


This worked for me upgrading to 2.1.1 -> Great answer and missing from all articles I could find.
This finally worked for me as well. After calling this in the pmc of VS2017 for each project I upgraded to v2.1.3 from v2.1.0
Install-Package Microsoft.NETCore.App
Why does it 'blocked by project' at all though? Is this some kind of bug or is there a good reason? if there's a good reason perhaps doing the above isn't a good idea? Or does it fix said problem?
Thanks for this hint. So "Blocked by project" turned out as "Blocked by VS NuGet GUI".
g
gsharp

For me adding

<TargetLatestRuntimePatch>true</TargetLatestRuntimePatch>

did the trick

<PropertyGroup>
  <TargetFramework>netcoreapp2.1</TargetFramework>
  <GenerateAssemblyInfo>false</GenerateAssemblyInfo>
  <TargetLatestRuntimePatch>true</TargetLatestRuntimePatch>
</PropertyGroup>

So this would target the latest version of the framework on the current machine. If local computer is patched and host server is then wouldn't this run into issues?
I actually don't know because we are doing self-contained deployments. But as a wild guess I would imagine since it says "latest" and no specific version that it would just not use any if not present. @jonmeyer
I had different versions installed in my solution. I edited all of them to add this line. Brought them to the same version and then deleted the line again. But I still get the message blocked by project when I manage nuget packages for solution.
@sam did you try the others solutions too? it seems that the two answers with 30+ votes also work for some people.
Yeah. I did. What i'm trying to do is use the manage nuget packages for solution option in the UI and install/ uninstall using mouse clicks. Not having to edit the csproj files manually. And I haven't been able to do that using the UI. Your way and the other options work, but the UI doesn't work.
b
bugged87

Short Answer

Add an explicit version to the Microsoft.AspNetCore.App package reference in your .csproj file.

Long Answer

I had a brand new netcoreapp2.1 project. The following was in the .csproj file. Note there was no version associated with the Microsoft.AspNetCore.App package reference.

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

I added an explicit reference to the Microsoft.Extensions.Logging.Abstractions package to resolve a dependency mismatch (build error). Micorsoft.AspNetCore.App wanted version 2.1.0 of this dependency, but another package wanted version 2.1.1. My .csproj file now looked like this.

<ItemGroup>
  ...
  <PackageReference Include="Microsoft.AspNetCore.App" />
  <PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="2.1.1" />
  ...
</ItemGroup>

This reduced the build error to a warning about Micorsoft.AspNetCore.App requiring the 2.1.0 version of the Microsoft.Extensions.Logging.Abstractions package but version 2.1.1, of course, was resolved.

Trying to update Micorsoft.AspNetCore.App to version 2.1.1 to fix the warning was blocked by Package Manager as mentioned by the OP.

I updated my Micorsoft.AspNetCore.App package reference to explicitly use version 2.1.1 like this.

<ItemGroup>
  ...
  <PackageReference Include="Microsoft.AspNetCore.App" Version="2.1.1" />
  <PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="2.1.1" />
  ...
</ItemGroup>

This fixed the build warning and unblocked all the versions of Microsoft.AspNetCore.App in Package Manager. I was even able to remove the explicit reference to Microsoft.Extensions.Logging.Abstractions without reintroducing the original error. The final .csproj looked like this with no issues.

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

d
ddagsan

I had same problem and I think, the problem is about the package.

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

The problem was resolved after I specified version exactly.

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

As I know, that error is occured when the version number


S
Shooresh

Another possible solution. In the csproj file, update the target framework to the version you wish to upgrade to. After making the change, as per below snippets, the packages can be upgraded via the solution NuGet package manager.

Before:

<PropertyGroup>
    <TargetFramework>netcoreapp2.0</TargetFramework>
</PropertyGroup>

After:

<PropertyGroup>
    <TargetFramework>netcoreapp2.1</TargetFramework>
</PropertyGroup>

h
harlandgomez

I solved it by simply: Right clicking on Project (or ALT+ Enter) -> Properties -> Application -> Target Framework (Choose .NET Core framework (in this case 1.1))


S
Shadi Alnamrouti

The best recommendation is to recreate your projects again after upgrading the SDK and the run time and then drop your old code and configuration inside the new projects. Other than that, you will be spending too much time in useless tweaks and unknown configurations.