Visual C++ 14 redist package prerequisite - configure from visual studio setup proj

florinp picture florinp · Jun 11, 2016 · Viewed 21.6k times · Source

I have a Visual Studio setup project which installs an x64 program that needs the VC++ 14 Redist package.

Setup how it looks

I selected the options as per image and created a folder structure inside:

C:\Program Files (x86)\Microsoft Visual Studio 14.0\SDK\Bootstrapper\Packages

I have created vcredist_x64 folder which contains:

vcredist_x64.exe
product.xml
en folder

Inside en folder I have:

package.xml

Contents of product.xml:

<?xml version="1.0" encoding="utf-8" ?> 

  <Product
    xmlns="http://schemas.microsoft.com/developer/2004/01/bootstrapper"
    ProductCode="Microsoft.Visual.C++.11.0.x64"
  >

  <!-- Defines list of files to be copied on build -->
  <PackageFiles>
  <PackageFile Name="vcredist_x64.exe" HomeSite="VCRedistExe"/>
  </PackageFiles>
  <InstallChecks>
    <MsiProductCheck Property="VCRedistInstalled" Product="{e46eca4f-393b-40df-9f49-076faf788d83}"/>
   </InstallChecks>

   <!-- Defines how to invoke the setup for the Visual C++ 11.0 redist -->
   <!-- TODO: Needs EstimatedTempSpace, LogFile, and an update of EstimatedDiskSpace -->
    <Commands Reboot="Defer">
    <Command PackageFile="vcredist_x64.exe" 
      Arguments=' /q:a ' 
      >

     <!-- These checks determine whether the package is to be installed -->
  <InstallConditions>
    <BypassIf Property="VCRedistInstalled" Compare="ValueGreaterThanOrEqualTo" Value="3"/>
    <!-- Block install if user does not have admin privileges -->
    <FailIf Property="AdminUser" Compare="ValueEqualTo" Value="false" String="AdminRequired"/>

    <!-- Block install on any platform other than x64 -->
    <FailIf Property="ProcessorArchitecture" Value="AMD64" Compare="ValueNotEqualTo" String="InvalidOS"/>

    <!-- Block install on Vista or below -->
    <FailIf Property="VersionNT" Compare="VersionLessThan" Value="6.00" String="InvalidPlatformWinNT"/>

  </InstallConditions>

  <ExitCodes>
    <ExitCode Value="0" Result="Success"/>
    <ExitCode Value="3010" Result="SuccessReboot"/>
    <DefaultExitCode Result="Fail" FormatMessageFromSystem="true" String="GeneralFailure" />
  </ExitCodes>

</Command>
 </Commands>
</Product>

Contents of en\package.xml:

<?xml version="1.0" encoding="utf-8" ?>

<Package
  xmlns="http://schemas.microsoft.com/developer/2004/01/bootstrapper"
  Name="DisplayName"
  Culture="Culture"
>

    <!-- Defines a localizable string table for error messages-->
    <Strings>
        <String Name="DisplayName">Visual C++ "14" Runtime Libraries (x64)</String>
        <String Name="Culture">en</String>
        <String Name="AdminRequired">You do not have the permissions required to install Visual C++  Runtime Libraries (x64). Please contact your administrator.</String>
        <String Name="InvalidOS">Installation of Visual C++  Runtime Libraries (x64) is supported only on x64 machines.</String>
        <String Name="GeneralFailure">A failure occurred attempting to install Visual C++  Runtime Libraries (x64).</String>
          <String Name="VCRedistExe">http://go.microsoft.com/fwlink/?LinkID=210622&amp;clcid=0x409</String>
     </Strings>

    </Package>

When I build the setup project, it gives no errors.

Initially when I didn't have that folder structure along with the xmls I had the error on build:

enable 'Download prerequisites from the same location as my application'   in the Prerequisites dialog box, you must download file 'vcredist_x64\vcredist_x64.exe' for item 'Visual C++ "14" Runtime Libraries (x64)' to your local machine. For more information, see http://go.microsoft.com/fwlink/?LinkId=616018.

However I have no errors now. The problem is that it does not install the VC redistributable dependency.

I believe that the productcode and other parameters are not correct in the xmls. Also the VCRedistExe link is for VC++2010 but it does not download anything during setup. However do note that I have the vcredist_x64.exe inside the folder structure which is the VC++14 redist.

Please help me as I have tried many other options as well, and this "official" option does not seem to work (I could not find relevant info Visual C++ Redistributable for Visual Studio 2015).

Either option is fine for me (download from website or download from the same location as my app) as long as the prerequisite is installed.