Jason
Jason

Reputation: 3689

How to prevent nuget from reverting to older versions of dependent packages when updating a package

When updating a nuget package to a new version, dependencies of the package being updated are removed and reinstated as the lowest allowable version of those dependent packages. The package manager console output is as follows:

Update-Package web.CMS -version 6.5.0-develop-140728152

Updating 'Web.CMS' from version '6.5.0-Trunk-1406031714' to '6.5.0-develop-1407281525' in project 'App.Cms'.

Remove 'Web.CMS 6.5.0-Trunk-1406031714' from project App.Cms.

Remove 'Cms.Assemblies 6.1.379' from project App.Cms.

Remove 'Web 7.3.0' from project App.Cms.

Remove 'Core 8.0.0-Trunk-1406251804' from project App.Cms.

Add 'Core 6.1.0' to project App.Cms.

Add 'Web 6.0.0' to project App.Cms.

Add 'Cms.Assemblies 6.0.530' to project App.Cms.

Add 'Web.CMS 6.5.0-develop-1407281525' to project App.Cms.

The dependencies section of the Web.CMS package nuspec file is as follows, as you can see the dependent package versions are those that have been installed as part of the package update.

<dependencies>
   <dependency id="Core" version="6.1" />
   <dependency id="Web" version="6.0" />
   <dependency id="Cms.Assemblies" version="[6.0.530,7)"/>
</dependencies>

Is there a way to update a package without the dependent packages reverting to older versions, as happens here? We can do it by uninstalling the package and installing the new version, that's for from ideal however as some packages are used by several projects in a solution and it has to be done for each project individually.

Upvotes: 4

Views: 1639

Answers (1)

Jason
Jason

Reputation: 3689

This was fixed by including the -IgnoreDependencies switch:

Update-Package web.CMS -version 6.5.0-develop-140728152 -IgnoreDependencies

Upvotes: 1

Related Questions