本文介绍了如何解决 aspnet core 2.1 中的版本冲突?(2.1.1 >= 2.1.0-rc1-final)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

尝试将 Microsoft.VisualStudio.Web.BrowserLink 2.1.1 作为 nuget 包添加到一个非常库存的文件 -> 新建 -> 项目 .net core 2.1 项目.

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).

我记得过去在 csproj 文件中做一些事情来重定向版本.我希望在核心中避免这种情况.

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

.csproj 文件:

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="FeaturesRegistration" />
  </ItemGroup>
  <ItemGroup>
    <Compile Remove="ControllersHomeController.cs" />
  </ItemGroup>
  <ProjectExtensions>
    <MonoDevelop>
      <Properties>
        <Policies>
          <VersionControlPolicy>
            <CommitMessageStyle LastFilePostfix=":&#xA;  " LineAlign="0" IncludeDirectoryPaths="True" />
          </VersionControlPolicy>
        </Policies>
      </Properties>
    </MonoDevelop>
  </ProjectExtensions>
</Project>

推荐答案

共享框架包 Microsoft.AspNetCore.App 应始终在没有版本号的情况下使用,如下所示:

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

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

这样,它将由运行时自动解析,运行时将包及其依赖项作为 .NET Core 的一部分提供,并将自动前滚补丁版本.因此,为了升级到 2.1.1,您应该只升级您的本地 .NET Core SDK,以及您部署到的服务器上的 .NET Core 运行时.

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) 

那里的版本是2.1.0-rc1-final.这表明您尚未针对 2.1.0 RTM 或 2.1.1 更新本地 SDK.您可以在此处下载当前 SDK v2.1.301.可以在此处找到所有下载内容,包括您服务器的运行时安装程序.

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.

这篇关于如何解决 aspnet core 2.1 中的版本冲突?(2.1.1 &gt;= 2.1.0-rc1-final)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-12 16:55