Add-BindingRedirect automation

Topics: Ecosystem, General
Feb 12, 2013 at 11:35 AM
Currently I am installing a package using this code:
var componentModel = GetGlobalService(typeof(SComponentModel)) as IComponentModel;
var installer = componentModel.GetService<IVsPackageInstaller>();
installer.InstallPackage(packageSource, project, packageId, packageVersion, false);
However, this does not behave exactly the same way as installing package manually. One has to execute this:
Add-BindingRedirect
to get the same effect. But how do I execute this command from my VsPackage. Or, alternatively, how do I get it executed during package installation?
Feb 15, 2013 at 12:39 PM
the binding redirect should happen automatically with you code. Are you certain that a binding redirect should take place in your case? What are the packages you are trying to install?
Feb 15, 2013 at 9:24 PM
I agree that it should, but it does not. When I install the package using automation the application does not start because of references to different versions of assemblies. When I create the same solution, but install the packages manually then the binding redirects appear in web.config and application starts correctly. The packages are our internal and not (yet) available on nuget.org.
Feb 17, 2013 at 3:11 PM
Can you describe to me what assemblies the packages contain and what are the relationship between them? What how are they installed into the projects?
Feb 18, 2013 at 9:32 AM
Edited Feb 18, 2013 at 9:34 AM
Not sure this is exactly the information you expect but let me try:

OpenWaves (1.0.84.266)
OpenWaves.EPiServer.ImageProperty (1.0.85.47); dependencies: OpenWaves.ImageTransformations.EPiServer (>= 1.0.84.899)
OpenWaves.ImageTransformations (1.0.84.953); dependencies: OpenWaves (>= 1.0.83.837)
OpenWaves.ImageTransformations.EPiServer (1.0.84.953); dependencies: OpenWaves.ImageTransformations.Web (>= 1.0.84.953), OpenWaves (>= 1.0.83.837)
OpenWaves.ImageTransformations.Web (1.0.84.953); dependencies: OpenWaves.ImageTransformations (>= 1.0.84.953), OpenWaves (>= 1.0.83.904)
OpenWaves.Web (1.0.84.927); dependencies: OpenWaves (>= 1.0.83.837)

The solution does not work without binding redirects for OpenWaves and OpenWaves.Web.