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

前端 未结 8 1805
陌清茗
陌清茗 2020-12-08 18:22

I have a dotnet core app that is targetting Microsoft.NETCore.App 1.1.2. I created a test project to test against that project but when building I noticed this warning:

8条回答
  •  南方客
    南方客 (楼主)
    2020-12-08 18:36

    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.

    
      ...
      
      ...
    
    

    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.

    
      ...
      
      
      ...
    
    

    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.

    
      ...
      
      
      ...
    
    

    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.

    
      ...
      
      ...
    
    

提交回复
热议问题