添加Visual C ++ 2012重新分发(x86)作为先决条件(自定义先决条件)

时间:2016-01-18 09:33:30

标签: prerequisites visual-c++-2012

我需要添加Visual C++ 2012 Redestribution (x86)作为我使用VS 2016创建的安装程序的先决条件。但为了做到这一点,我必须在bootsrapper中创建product.xmlpackage.xml夹。许多帖子建议使用Bootstrapper Manifest Generator生成这些xml文件。但是微软现在已经存档了该工具,因此我没有生成文件的工具。

有什么方法可以使Visual C++ 2012 Redestribution (x86)成为我的安装程序的先决条件?

1 个答案:

答案 0 :(得分:7)

我已经回答了类似的问题Add prerequisites to visual studio 2015。但是,如果其他问题被删除或链接无法使用,我会再次发布答案。

  

我将解释我将Microsoft C++ 2013 x86添加到Visual Studio 2015文件夹中所使用的步骤(您案例中的步骤将类似)。

     

首先导航到C:\Program Files (x86)\Microsoft Visual Studio 14.0\SDK\Bootstrapper\Packages\文件夹(对于以前版本的Visual Studio或自定义路径,这可能会有所不同)。

     

找到Packages文件夹后,您可以创建一个名为vc_redist_2013_x86的新文件夹(在您的案例中为vc_redist_2010_x86)。   从Microsoft站点下载Redistribution包并将其放在此文件夹中。您可以从here下载2013版本,从here下载2010 x86。

     

现在将文件从vcredist_x86复制到您的文件夹(它应该是一个product.xml文件和一个带有package.xml文件的en文件夹)。现在删除它们的只读标志并在任何文本编辑器中打开。

     

如果是product.xml,您应该替换以下内容:

     
      
  • ProductCode to:" Microsoft.Visual.C ++。12.0.x86" (你将拥有C ++。10.0.x86)
  •   
  • PackageFile Name =" vcredist_x86.exe"将被命名为您从Microsoft站点下载的可执行文件。
  •   
  • 需要根据exe文件之一更改PublicKey。要找到它,您必须执行以下步骤:      
        
    • 右键单击exe文件(在我的情况下为vcredist.exe)
    •   
    • 选择'属性'
    •   
    • 选择'数字签名'
    •   
    • 选择顶部签名(sha1)
    •   
    • 按'详细信息'
    •   
    • 按'查看证书'
    •   
    • 选择'详细信息标签'
    •   
    • 选择公钥'
    •   
    • 从下方复制值,并在删除具有搜索值的空格后
    •   
  •   
  • MsiProductCheck产品需要更改为您的版本。我能够找到具有所需值的this答案。对于2013 x86,您的产品为{f65db027-aff3-4070-886a-0d87064aabb1},2010 x86为{1D5E3C0FEDA1E123187686FED06E995A}
  •   
     

保存文件并移至package.xml文件。在这里你必须替换' Visual C ++" 14"'你用过的版本。我将其替换为' Microsoft Visual C ++ 2013 Redistributable(x86)'。

     

完成此步骤后。您应该可以在Microsoft Visual C++ 2013 Redistributable (x86)的“先决条件”列表中看到Visual Studio 2015

     

如果您需要可以使用的模型,我会发布以下两个文件。

     

<强> Product.xml        

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

  <!-- Defines list of files to be copied on build -->
  <PackageFiles CopyAllPackageFiles="false">
    <PackageFile Name="vcredist_x86.exe" HomeSite="VCRedistExe" PublicKey="3082010a028201010096715ded0646fa84cb9d5bb746c7b0e1b4113903adb11573609ceba7b66e1a3c3fff65e334f1a6a5215e56996c58e492a10a5cc2d3dc522f0c659a20614053319c6c8f217dbaf9fe13505260953a5bb958a5746141a994e0ad264e4ca1977049275e7c67ca4f1e718446bc1d4bb6e20fc5c627c907e67a0aa51700194c7045382d81b450aac567d1fa79bcc5cca1729bf4253498f854df123938122fa46ba59a7ec762d1dccfed3d34f8b9df3530baec7932a9e1a9ac554d4c7f4c56c3130b76f107f9cc47acfb88d552a51e28fa3d2dcfcf849886716511cf85c9094486e16fe7b1fcac4044a5a98b233f82499dd596595013591873ff430cad2bd47f3040670203010001" />
  </PackageFiles>

  <InstallChecks>
    <MsiProductCheck Property="VCRedistInstalled" Product="{f65db027-aff3-4070-886a-0d87064aabb1}"/>
  </InstallChecks>

  <!-- Defines how to invoke the setup for the Visual C++ 14.0 redist -->
  <Commands Reboot="Defer">
    <Command PackageFile="vcredist_x86.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 Win95 -->
        <FailIf Property="Version9X" Compare="VersionLessThan" Value="4.10" String="InvalidPlatformWin9x"/>
        <!-- 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>
  

<强> package.xml中       

<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">Microsoft Visual C++ 2013 Redistributable (x86)</String>
        <String Name="Culture">en</String>
        <String Name="AdminRequired">You do not have the permissions required to install Microsoft Visual C++ 2013 Redistributable (x86). Please contact your administrator.</String>
        <String Name="InvalidPlatformWin9x">Installation of Microsoft Visual C++ 2013 Redistributable (x86) is not supported on Windows 95. Contact your application vendor.</String>
        <String Name="InvalidPlatformWinNT">Installation of Microsoft Visual C++ 2013 Redistributable (x86) is not supported on Windows NT 4.0. Contact your application vendor.</String>
        <String Name="GeneralFailure">A failure occurred attempting to install Microsoft Visual C++ 2013 Redistributable (x86).</String>
        <String Name="VCRedistExe">http://go.microsoft.com/fwlink/?LinkID=800028&amp;clcid=0x409</String>
    </Strings>

</Package>
  

希望它有所帮助,并且很容易遵循这个漫长的过程。