Reputation: 122212
I am already using the DocumentFormat.Ooxml
package and would like to also use ClosedXml
which depends on an older version of the same library so I get:
PM> Install-Package closedxml
Attempting to resolve dependency 'DocumentFormat.OpenXml (= 1.0)'.
Installing 'DocumentFormat.OpenXml 1.0'.
Successfully installed 'DocumentFormat.OpenXml 1.0'.
Installing 'ClosedXML 0.69.2'.
Successfully installed 'ClosedXML 0.69.2'.
Install failed. Rolling back...
Install-Package : Already referencing a newer version of 'DocumentFormat.OpenXml'.
Does nuget actually have a solution for this situation? Even if I could do assembly redirection (which I've always had mixed results with in unit tests) I don't see a -Force
parameter on Install-Package
.
Edit: Cross posted on the nuget discussion board
Upvotes: 3
Views: 771
Reputation: 4164
There are no plans at current for allowing multiple versions of a package to be installed into a single project at once. This would generally lead to conflicts as there would need to be 2 assemblies with the same name referenced (and in the bin folder).
The issue here is that ClosedXML has a version-specific dependency on DocumentFormat.OpenXml. You can contact the owner of ClosedXML to see if they can publish a new version that allows for different versions of DocumentFormat.OpenXml to be used.
If that isn't successful, then you can try to break yourself out of this conflict by doing the following:
This will result in a binding redirect getting added to your app/web.config file, like this:
<configuration>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="DocumentFormat.OpenXml" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-2.5.5631.0" newVersion="2.5.5631.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
Then you'll need to test your consumption of ClosedXML to see if the newer version of DocumentFormat.OpenXml can really be used with it. If it works, you'll certainly want to let the owners of ClosedXML know that (using the Contact Owners link on www.nuget.org for the package), so that they might move forward with updating the package with a new version that allows the newer DocumentFormat.OpenXml.
Upvotes: 2