将Visual C++ 2012 Redestribution (x86)添加为先决条件(自定义先决条件)

4
我需要将Visual C++ 2012 Redestribution (x86)作为我使用VS2016创建的安装程序的先决条件添加。但是,为了做到这一点,我必须在引导程序文件夹中创建product.xmlpackage.xml。许多帖子建议使用Bootstrapper Manifest Generator来生成这些XML文件。然而,Microsoft已经归档了该工具,因此我没有用于生成文件的工具。
有没有办法使Visual C++ 2012 Redestribution(x86)成为我的安装程序的先决条件呢?
1个回答

7

我已经回答过类似的问题了在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 package 并将其放置在此文件夹中。您可以从这里下载 2013 版本,从这里下载 2010 x86 版本。
现在将文件从“vcredist_x86”复制到您的文件夹中(应该是一个 product.xml 文件和一个带有 package.xml 文件的 en 文件夹)。现在删除它们的只读标记并在任何文本编辑器中打开。
在处理“product.xml”时,您应该替换以下内容:
ProductCode 替换为:“Microsoft.Visual.C++.12.0.x86”(您将拥有 C++.10.0.x86) PackageFile Name =“vcredist_x86.exe”将命名为您从 Microsoft 网站下载的可执行文件。 PublicKey 需要根据 exe 文件进行更改。为了找到它,您必须执行以下步骤:
右键单击 exe 文件(在我的情况下为 vcredist.exe) 选择“属性” 选择“数字签名” 选择顶部签名(sha1) 按“详细信息” 按“查看证书” 选择“详细信息”选项卡 选择“公共密钥” 从下面复制值并删除空格后,您将获得所搜索的值
MsiProductCheck 产品需要更改为您版本的产品。我能够找到这个带有所需值的答案。对于 2013 x86,您的 Product 是 {f65db027-aff3-4070-886a-0d87064aabb1},而对于 2010 x86,则为 {1D5E3C0FEDA1E123187686FED06E995A}。
保存文件并移动到“package.xml”文件。在这里,您必须将“Visual C++ "14"”替换为您使用的版本。我将其替换为“Microsoft Visual C++ 2013 Redistributable (x86)”。
完成这些步骤后,您应该能够在您的 Visual Studio 2015 的 Prerequisites 列表中看到“Microsoft Visual C++ 2013 Redistributable (x86)”。
我会在下面发布两个文件,以防您需要一个可以工作的模型。 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>

希望这篇内容能够帮助到您,并且很容易理解这个繁琐的过程。

感谢您的回答,尽管这个问题已经超过1年了。当时我能够通过执行这些确切的步骤来解决它。为了将来的参考,我会将其标记为已接受的答案。 - Janitha Tennakoon

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接