VC++ 2010 and VC++2012 Redistributables prerequisites for Visual Studio 2015 Setup project

1.7k Views Asked by At

I have Visual Studio 2015 installed, and I've built a .NET 4.6 application which depends on some third-party .NET assemblies, which depend on some C++ DLLs and EXEs, which in turn depend on the Visual C++ 2012 x64 Redistributable. The SDK I'm using includes some merge modules which deploy the SDK's .NET and C++ assemblies that I depend on (but not the Visual C++ runtimes).

If the Visual C++ 2012 redistributable isn't installed on a target machine, my .NET 4.6 app crashes on startup, saying Unhandled Exception: System.IO.FileNotFoundException: Could not load file or assembly 'MyManagedDependency.dll' or one of its dependencies. The specified module could not be found. This occurs even when I have the Visual C++ 2015 redistributables installed on the target system. So it appears that the C++ runtime dependency isn't backwards/forwards compatible.

I'm using a Visual Studio 2015 Setup Project to create the installer for my application. However, the list of installer Prerequisites I can select from doesn't include the Visual C++ 2012 Runtime Libraries. The only Visual C++ libraries I can select as setup project pre-requisites are the 'Visual C++ "14" Runtime Libraries'. I believe these are the same thing as the Visual C++ 2015 Redistributable, which isn't sufficient for my software to load.

Is there any way to add the Visual C++ 2012 runtime to the pre-requisite list for my VS2015 Setup Project installer (for example, by installing more SDKs)? Or is there another way I should be packaging the 2012 C++ runtime in my installer?

EDIT: Digging through the documentation & installer package of the third-party SDK I'm using, it looks like my application might actually only run correctly if both the Visual C++ 2010 and 2012 redistributables are present on the target system. Also I might need to install both the x86 and x64 versions. I don't think I can install all of those with merge modules since this page says:

We recommend that you not use merge modules except when you don't have to service your application and you don't have dependencies on more than one version of the DLLs. Merge modules for different versions of the same DLL cannot be included in one installer, and merge modules make it difficult to service DLLs independently of your application. Instead, we recommend that you install a Visual C++ Redistributable Package.

How can I add these older redistributables as pre-requisites for my VS2015 Setup Project?

1

There are 1 best solutions below

1
On

Several hours of research later, I've found that it's certainly possible to add items to the Visual Studio 2015 Setup Project Prerequisites dialogue box.

Combining this answer with VS2015's updated Bootstrapper path (\Program Files (x86)\Microsoft Visual Studio 14.0\SDK\Bootstrapper\Packages) from this MSDN article would achieve that goal.

However, that would leave me with a setup project that would only build properly in a fairly heavily customized build environment, which would be tricky to reproduce on new machines. I have found no simple-to-install VS add-on or MS package which would add this support.

In the end, the approach I'm now taking is to add the following MS merge modules to my setup project:

  • Microsoft_VC110_CRT_x86.msm
  • Microsoft_VC110_CRT_x64.msm
  • Microsoft_VC120_CRT_x86.msm
  • Microsoft_VC120_CRT_x64.msm

This results in the runtime DLLs getting deployed to C:\Windows\System32 and C:\Windows\SysWOW64, and they seem to work. This does not result in the Redistributable appearing in the Windows "Programs and Features" dialogue.

However, since MS recommends against this method of deploying the runtimes, I'm open to any easier-to-maintain method for packaging the "true" VC++ 2010 and VC++ 2012 Redistributable with my VS2015 Setup Project.