繁体   English   中英

有没有办法在旧的 csproj 格式项目中将具有多个相互依赖项的 nuget 包更新到较新的版本?

[英]Is there a way to update nuget package with multiple interdependent dependencies to a newer version in an old csproj format project?

我们有一个旧的(VS2017 之前)格式的 csproj 项目的 Visual Studio 解决方案,它依赖于Microsoft.TeamFoundationServer.ExtendedClient 15.112.1 ,它有相当多的其他(相互)依赖项。

问题是,即使在新的独立项目中,也不可能将(在 VS2017 中)依赖项更新到较新的15.131.1版本。 始终存在以下错误(无论我尝试了哪些选项):

PM> Update-Package Microsoft.TeamFoundationServer.ExtendedClient

Attempting to gather dependency information for multiple packages with respect to project 'TestTfsNugetUpdate', targeting '.NETFramework,Version=v4.5'
Gathering dependency information took 6.98 sec
Attempting to resolve dependencies for multiple packages.
Update-Package : Unable to find a version of 'Microsoft.VisualStudio.Services.Client' that is compatible with 'Microsoft.TeamFoundation.DistributedTask.Common 15.112.1 constraint: Microsoft.VisualStudio.Services.Client (= 
15.112.1)'.At line:1 char:1

虽然同一个独立的格式项目没有这样的问题

<Project Sdk="Microsoft.NET.Sdk">    
  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>net45</TargetFramework>
  </PropertyGroup>    
  <ItemGroup>
    <PackageReference Include="Microsoft.TeamFoundationServer.ExtendedClient" Version="15.112.1" />
  </ItemGroup>    
</Project>

作为

Update-Package Microsoft.TeamFoundationServer.ExtendedClient -DependencyVersion Highest
Restoring packages for C:\Projects\TEST\TestTfsNugetUpdate\TestTfsNugetPackage_NewFormat\TestTfsNugetPackage_NewFormat.csproj...
Installing NuGet package Microsoft.TeamFoundationServer.ExtendedClient 15.131.1.
...
Successfully installed 'System.IdentityModel.Tokens.Jwt 5.1.5' to TestTfsNugetPackage_NewFormat
Executing nuget actions took 97.55 ms

因此,基本上有一种方法可以使用旧格式项目来完成它,而无需求助于手动/半自动删除和重新安装具有依赖项的 ExtendedClient(问题是该解决方案包括许多可能依赖或不依赖 TFS dll 的项目,所以我不能只为每个项目删除+安装它)?

PS:无论如何,将所有内容移植到新格式是个好主意,但目前我不想进行。

有没有办法在旧的 csproj 格式项目中将具有多个相互依赖项的 nuget 包更新到较新的版本?

我很抱歉这么晚才回复,我不确定这个答案是否对您有帮助。

我可以在我这边重现这个问题,但似乎我们必须卸载并重新安装15.131.1版本。

就像你说的,包Microsoft.TeamFoundationServer.ExtendedClient有多个相互依赖的依赖关系,比如:

Microsoft.VisualStudio.Services.Client (= 15.112.1)

Microsoft.TeamFoundationServer.Client (= 15.112.1)

但是,依赖项Microsoft.TeamFoundationServer.Client也有一个间接依赖项Microsoft.VisualStudio.Services.Client (= 15.112.1) 当我们更新包Microsoft.TeamFoundationServer.ExtendedClient ,nuget 将首先更新包Microsoft.VisualStudio.Services.Client (= 15.112.1) ,但包Microsoft.TeamFoundationServer.Client (= 15.112.1)仍然引用它,会阻止我们从更新包。

反过来也是一样的。 这个包的多个相互依赖的依赖形成了一个死锁,我们暂时无法打破它,除非我们使用选项忽略依赖升级每个依赖。

因此,我们必须卸载并重新安装15.131.1版本。

问题是该解决方案包括许多可能依赖或不依赖 TFS dll 的项目,所以我不能为每个项目删除+安装它

您可以使用选项Manage Nuget packages for solution... ,并选中项目复选框,将选择安装该包的所有项目:

在此处输入图片说明

因此,您无需为每个项目一一卸载并重新安装包。

希望这可以帮助。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM