Sharada
Sharada

Reputation: 13611

Force package version update when dependency package is updated

Problem statement

We have a local nuget store with a list of components, which are used by a number of apps.

All of them always have a core component (let's say PackageB) defined as a dependency. From nuget graph perspective, we can say there's a lot of cousin-dependencies in there.

cousin dependency graph

Let's assume core component PackageB has interface-types defined as InterfaceA, and InterfaceC.

PackageA has ClassA which implements InterfaceA. PackageC has ClassC which implements InterfaceC.

PackageA, and PackageC both have defined PackageB as a dependency as shown in image above.

As part of an update, we made some changes in InterfaceA, and ClassA. Accordingly, new versions were created for PackageA, and PackageB, and we upgraded to these versions in our app.

We didn't realize that, another team had similarly made changes to InterfaceC, ClassC; and had generated a new version for PackageC - an update that we didn't need in our app. So we didn't upgrade PackageC.

There were no compile-time errors. It was only while testing the app, we started encountering following error:

"VTable setup of type ClassC failed" (Android project)

The root cause for the issue turned out to be that when we updated PackageB, we ended up with the newer InterfaceC, which was no longer compatible with the older version of PackageC. So, upgrading to latest version of PackageC solved the issue.

Question

To avoid this problem, I want to be able to force an update to all dependent packages whenever a core package like PacakgeB is updated in the target project.

i.e. if PacakgeB is updated, it should automatically force an update to PacakgeA and PackageC. Is this possible?

I am assuming that there is some specification which can instruct nuget or msbuild to handle this at app-project level.

Upvotes: 3

Views: 827

Answers (1)

Dmitry Zinoviev
Dmitry Zinoviev

Reputation: 588

It seems like you need to specify right versions in app.config

Here it is my app.config from my project

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="XLabs.Serialization" publicKeyToken="d65109b36e5040e4" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-2.0.5782.15703" newVersion="2.0.5782.15703" />
      </dependentAssembly>
    </assemblyBinding>
  </runtime>
</configuration>

you will need to change publicKeyToken and set right version number

Upvotes: 1

Related Questions