简体   繁体   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?

We have a Visual Studio solution with old(pre VS2017) format csproj projects with dependency on Microsoft.TeamFoundationServer.ExtendedClient 15.112.1 that has a fair share of other (inter)dependencies it requires.我们有一个旧的(VS2017 之前)格式的 csproj 项目的 Visual Studio 解决方案,它依赖于Microsoft.TeamFoundationServer.ExtendedClient 15.112.1 ,它有相当多的其他(相互)依赖项。

The problem is that even in a new standalone project it is impossible to update (in VS2017) dependency to the newer 15.131.1 version.问题是,即使在新的独立项目中,也不可能将(在 VS2017 中)依赖项更新到较新的15.131.1版本。 There is always the following error (regardless of the options I try):始终存在以下错误(无论我尝试了哪些选项):

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

While the same standalone new format project has no such issues虽然同一个独立的格式项目没有这样的问题

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

As作为

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

So, basically is there a way to do it with old format project without resorting to manual/semiautomatic removal and reinstallation of the ExtendedClient with dependencies (the problem is that the solution includes a lot of projects that may or may not depend on TFS dlls, so I can't just remove+install it for each project)?因此,基本上有一种方法可以使用旧格式项目来完成它,而无需求助于手动/半自动删除和重新安装具有依赖项的 ExtendedClient(问题是该解决方案包括许多可能依赖或不依赖 TFS dll 的项目,所以我不能只为每个项目删除+安装它)?

PS: Porting everything to a new format is a nice idea in any case, but it is not something I'd like to undertake at the moment. PS:无论如何,将所有内容移植到新格式是个好主意,但目前我不想进行。

Is there a way to update nuget package with multiple interdependent dependencies to a newer version in an old csproj format project?有没有办法在旧的 csproj 格式项目中将具有多个相互依赖项的 nuget 包更新到较新的版本?

I am sorry for this late reply, I am not sure if this answer is helpful to you.我很抱歉这么晚才回复,我不确定这个答案是否对您有帮助。

I could reproduce this issue on my side, but it seems we have to uninstall and reinstall the version 15.131.1 .我可以在我这边重现这个问题,但似乎我们必须卸载并重新安装15.131.1版本。

Just like you said, the package Microsoft.TeamFoundationServer.ExtendedClient has multiple interdependent dependencies, like:就像你说的,包Microsoft.TeamFoundationServer.ExtendedClient有多个相互依赖的依赖关系,比如:

Microsoft.VisualStudio.Services.Client (= 15.112.1)

Microsoft.TeamFoundationServer.Client (= 15.112.1)

However , the dependencies Microsoft.TeamFoundationServer.Client also has a indirect dependence Microsoft.VisualStudio.Services.Client (= 15.112.1) .但是,依赖项Microsoft.TeamFoundationServer.Client也有一个间接依赖项Microsoft.VisualStudio.Services.Client (= 15.112.1) When we update the package Microsoft.TeamFoundationServer.ExtendedClient , nuget will update package Microsoft.VisualStudio.Services.Client (= 15.112.1) first, but package Microsoft.TeamFoundationServer.Client (= 15.112.1) still reference it, will prevent us from updating the package.当我们更新包Microsoft.TeamFoundationServer.ExtendedClient ,nuget 将首先更新包Microsoft.VisualStudio.Services.Client (= 15.112.1) ,但包Microsoft.TeamFoundationServer.Client (= 15.112.1)仍然引用它,会阻止我们从更新包。

The reverse is the same.反过来也是一样的。 Multiple interdependent dependencies of this package form a deadlock, we could not break it for now unless we upgrade every dependencies with option ignore dependencies.这个包的多个相互依赖的依赖形成了一个死锁,我们暂时无法打破它,除非我们使用选项忽略依赖升级每个依赖。

So, we have to uninstall and reinstall the version 15.131.1 .因此,我们必须卸载并重新安装15.131.1版本。

the problem is that the solution includes a lot of projects that may or may not depend on TFS dlls, so I can't just remove+install it for each project问题是该解决方案包括许多可能依赖或不依赖 TFS dll 的项目,所以我不能为每个项目删除+安装它

You can use the option Manage Nuget packages for solution... , and select the project checkbox, all the project which installed that package will be selected:您可以使用选项Manage Nuget packages for solution... ,并选中项目复选框,将选择安装该包的所有项目:

在此处输入图片说明

So, you do not need uninstall and reinstall the package for each project one by one.因此,您无需为每个项目一一卸载并重新安装包。

Hope this helps.希望这可以帮助。

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

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