简体   繁体   中英

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.

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

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.

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

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 .

Just like you said, the package Microsoft.TeamFoundationServer.ExtendedClient has multiple interdependent dependencies, like:

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

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 .

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

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:

在此处输入图片说明

So, you do not need uninstall and reinstall the package for each project one by one.

Hope this helps.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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