如何解决ASPNET Core 2.1中的版本冲突? (2.1.1> = 2.1.0

编程入门 行业动态 更新时间:2024-10-22 05:17:16
本文介绍了如何解决ASPNET Core 2.1中的版本冲突? (2.1.1> = 2.1.0-rc1-final)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

尝试将Microsoft.VisualStudio.Web.BrowserLink 2.1.1作为nuget包添加到非常库存的文件->新建-> Project 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。您可以在此处下载当前SDK v2.1.301 。可以在在此处找到所有下载内容,包括服务器的运行时安装程序。

>

Trying to add Microsoft.VisualStudio.Web.BrowserLink 2.1.1 as a nuget package on a very stock File -> New -> Project 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

本文发布于:2023-11-14 14:58:06,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1587644.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:如何解决   冲突   版本   ASPNET   Core

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!