Search code examples
c#visual-c++setup-project

Visual Studio 2022 Installer not Bundling VC++ Redistributable


We have a C# application using a C++ wrapper DLL class in a C++ project.

When we created the setup/msi and installed it, the application is not running, as the necessary files referenced by the Visual Studio include directory are missing with the installation.


Solution

  • Assuming you are using the "Microsoft Visual Studio Installer Projects" extension, then you can 'instruct' the "Setup.exe" file you create to download and install the VC++ Redistributable (if required) before it runs the actual ".msi" installer package.

    You do this by specifying that redistributable as a "prerequisite". Right-click on the installer project in the Solution Explorer pane and select the "Properties" command; then, in the pop-up displayed, click the "Prerequisites..." button. You will see another pop-up, like below:

    enter image description here

    Be sure that the "Create setup program..." box is checked, then scroll down the list box to (near) the bottom and check the relevant "Visual C++ "14" Runtime Libraries" package for your target platform.

    With this setting, the generated "Setup.exe" file will then verify if an installation or update of the redistributable is needed and, if so, will manage its download and installation from the selected website. (Note that the redistributables are the same for all versions of Visual Studio since v.14, so it will be valid for VS 2022.)