Microsoft.AspNetCore.App 2.1.1 upgrade “Blocked by project”

后端 未结 8 1555
死守一世寂寞
死守一世寂寞 2020-12-05 04:05

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 t

相关标签:
8条回答
  • 2020-12-05 04:18

    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> 
    
    0 讨论(0)
  • 2020-12-05 04:18

    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 讨论(0)
  • 2020-12-05 04:18
    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.
    0 讨论(0)
  • 2020-12-05 04:27

    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" />
    
    0 讨论(0)
  • 2020-12-05 04:32

    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.

    0 讨论(0)
  • 2020-12-05 04:35

    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 讨论(0)
提交回复
热议问题