How do I resolve version conflicts in aspnet core 2.1? (2.1.1 >= 2.1.0-rc1-final)

半城伤御伤魂 提交于 2019-12-08 05:09:56

问题


Trying to add Microsoft.VisualStudio.Web.BrowserLink 2.1.1 as a nuget package on a very stock File -> New -> Project .net core 2.1 project.

Version conflict detected for Microsoft.AspNetCore.Hosting.Abstractions.    Reference the package directly from the project to resolve this issue. 
EngineeringWeb (>= 1.0.0) -> Microsoft.VisualStudio.Web.BrowserLink (>= 2.1.1) -> Microsoft.AspNetCore.Hosting.Abstractions (>= 2.1.1) 
EngineeringWeb (>= 1.0.0) -> Microsoft.AspNetCore.App (>= 2.1.0-rc1-final) -> Microsoft.AspNetCore.Hosting.Abstractions (>= 2.1.0-rc1-final).

I recall doing things in csproj files in the past to redirect versions. I was hoping to avoid that with in core.

The .csproj file:

<Project Sdk="Microsoft.NET.Sdk.Web">

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

  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
    <TreatWarningsAsErrors>true</TreatWarningsAsErrors>
  </PropertyGroup>
  <ItemGroup>
    <PackageReference Include="Microsoft.AspNetCore.App" Version="2.1.1" />
  </ItemGroup>

  <ItemGroup>
    <Folder Include="Features\" />
    <Folder Include="Features\Registration\" />
  </ItemGroup>
  <ItemGroup>
    <Compile Remove="Controllers\HomeController.cs" />
  </ItemGroup>
  <ProjectExtensions>
    <MonoDevelop>
      <Properties>
        <Policies>
          <VersionControlPolicy>
            <CommitMessageStyle LastFilePostfix=":&#xA;  " LineAlign="0" IncludeDirectoryPaths="True" />
          </VersionControlPolicy>
        </Policies>
      </Properties>
    </MonoDevelop>
  </ProjectExtensions>
</Project>

回答1:


The shared framework package Microsoft.AspNetCore.App should always be used without a version number, like this:

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

That way, it will be resolved automatically by the runtime, which ships the packages and its dependencies as part of .NET Core, and will automatically roll forward patch releases. So in order to upgrade to 2.1.1, you should just upgrade your local .NET Core SDK, and the .NET Core runtime on the server you deploy to.

As for your problem, if you look at the output, you will see the following:

Microsoft.AspNetCore.App (>= 2.1.0-rc1-final) 

The version there is 2.1.0-rc1-final. This suggest that you have not updated your local SDK for neither 2.1.0 RTM nor to 2.1.1. You can download the current SDK v2.1.301 over here. All downloads, including the runtime installers for your server can be found over here.



来源:https://stackoverflow.com/questions/51031148/how-do-i-resolve-version-conflicts-in-aspnet-core-2-1-2-1-1-2-1-0-rc1-final

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!