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

问题描述

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



版本冲突。直接从项目中引用该软件包即可解决此问题。
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文件中处理重定向版本。我希望避免这种情况出现在内核中。



.csproj文件:

 < 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 =功能\注册\ />
< / ItemGroup>
< ItemGroup>
< Compile Remove = Controllers\HomeController.cs />
< / ItemGroup>
< ProjectExtensions>
< MonoDevelop>
<属性>
< Policies>
< VersionControlPolicy>
< CommitMessageStyle LastFilePostfix =:& #xA; LineAlign = 0 IncludeDirectoryPaths = True />
< / VersionControlPolicy>
< / Policies>
< / Properties>
< / MonoDevelop>
< / ProjectExtensions>
< / Project>


解决方案

共享框架包 Microsoft .AspNetCore.App 应该始终不带版本号使用,例如:

 < PackageReference Include = Microsoft.AspNetCore.App /> 

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



对于您的问题,如果查看输出,将看到以下内容:

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

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

>

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>
解决方案

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.

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

10-12 16:55