Using two different versions of same the nuget package

北城余情 提交于 2019-12-01 02:31:30

As already stated there is nothing wrong with referencing 2 different versions of of a nugget package, as long as it's in different Visual Studio Projects that those references are made.

But this is also where the easy part ends, but I think there are a few options left. Depending on your needs I see the following options.

  1. Create a post build step which register the multi versioned assemblies into the GAC. As long as each assembly have different assembly version, the CLR will pick up the right assembly from the GAC when needed.
  2. Create a post build step which copy the different assemblies into a subfolder of you application bin folder like bin/package-v1 and bin/package-v2. Then you can in your application override the AssemblyResolve event like described here https://msdn.microsoft.com/en-us/library/ff527268(v=vs.110).aspx. This will make it possible for you to load the assembly in the right version at the time of need.
  3. If you don't want to play around with AssemblyResolve, then you can also modify your web/app.config to do assembly redirect/probing as described here https://msdn.microsoft.com/en-us/library/4191fzwb(v=vs.110).aspx

Hope this helps a bit, so you don't have to modify third party source code next time.

OK so, I solve this by downloading whole sourcecode for 2.X wrapper version. Renamed its namespace to ABCDEF2 where ABCDEF was original namespace. Build my own nuget package with my own key and... publish it to our private nuget server. This is such a lame solution but there is no other way than manually downloading the original packages and reference it directly with different filename etc and you loose nuget advantages.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!