为ClickOnce先决条件指定VC++ Redistributable版本

8
我的ClickOnce应用程序使用了一个需要Visual C++ 2005可再发行组件的第三方工具。如果只安装了VC++ 2008可再发行组件,则该第三方工具将无法正常工作。然而,在Visual Studio 2008中,ClickOnce先决条件不允许指定VC++可再发行组件的版本;它会添加一个VC++ 2008先决条件,这在大多数情况下是有意义的。然而,在这种情况下,需要较早的版本。由于需要ClickOnce,因此合并模块是不可行的。有没有什么办法可以指定版本?
3个回答

8
如果您能找到安装了VS 2005的计算机,解决方案就不会太难。您可以自定义在项目的发布选项卡上出现的先决条件对话框。
  1. 在安装有VS 2005的计算机上,转到\Program Files\Microsoft Visual Studio 8\SDK\v2.0\BootStrapper\Packages并将vsredist_x86文件夹复制到要发布的计算机。
  2. 重命名文件夹,称其为vsredist_x86_2005或类似的名称。
  3. 在文件夹内,编辑\en\package.xml文件。更改<String Name="DisplayName">标记以使其有意义(例如:Visual C++ 2005 Runtime Libraries (x86)),以区分其与现有的2008包。
  4. 将文件夹复制到C:\Program Files\Microsoft SDKs\Windows\v6.0A\Bootstrapper\Packages
  5. 如果已打开Visual Studio,请重新启动它。

现在,当您打开先决条件对话框时,您应该会看到一个新的2005包条目。我没有完全测试这个解决方案,所以可能会漏掉一些细节,但希望这可以帮助您入门。


1
微软又一次展现了它的微软风格。 - N. Kudryavtsev

0

我相信您可以打开应用程序的清单文件,并修改应用程序应链接的redists版本。清单中的列表应与您在C:\ Windows \ WinSxS目录中拥有的内容匹配。这里有一个CodeProject页面,其中提供了使用不同可再发行组件的良好描述。


这是正确的;然而,它不会影响已安装的先决条件。即使清单指定了2005 redists,ClickOnce安装程序也只会安装2008 redists,导致依赖关系仍未解决。 - Tarsier

0

我刚刚安装了Visual Studio 2005。这是一个原始的引导程序:

C:\Program Files\Microsoft Visual Studio 8\SDK\v2.0\BootStrapper\Packages\vcredist_x86\

\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++ Runtime Libraries (x86)</String>
        <String Name="Culture">en</String>
        <String Name="AdminRequired">You do not have the permissions required to install Visual C++ Runtime Libraries (x86). Please contact your administrator.</String>
        <String Name="InvalidPlatformWin9x">Installation of Visual C++ Runtime Libraries (x86) is not supported on Windows 95. Contact your application vendor.</String>
        <String Name="InvalidPlatformWinNT">Installation of Visual C++ Runtime Libraries (x86) is not supported on Windows NT 4.0. Contact your application vendor.</String>
        <String Name="GeneralFailure">A failure occurred attempting to install Visual C++ Runtime Libraries (x86).</String>
    </Strings>

</Package>

\product.xml

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

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

  <!-- Defines list of files to be copied on build -->
  <PackageFiles>
    <PackageFile Name="vcredist_x86.exe"/>
  </PackageFiles>

  <InstallChecks>
    <MsiProductCheck Property="VCRedistInstalled" Product="{A49F249F-0C91-497F-86DF-B2585E8E76B7}"/>
  </InstallChecks>

  <!-- Defines how to invoke the setup for the Visual C++ 8.0 redist -->
  <!-- TODO: Needs EstrimatedTempSpace, LogFile, and an update of EstimatedDiskSpace -->
  <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 NT 4 or less -->
        <FailIf Property="VersionNT" Compare="VersionLessThan" Value="5.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>

\vcredist_x86.exe

SHA1: 95040f80b0d203e1abaec4e06e0ec0e01c507d03

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