使用VS2017安装程序项目安装vcredist_x64

时间:2018-02-28 14:56:49

标签: visual-studio-2017 setup-project visual-studio-setup-proje

我目前想为VS2017项目创建一个安装程序。该项目具有vcredist_x64作为先决条件。

要创建我已安装的安装程序: - ClickOnce Publishing(通过VS2017安装程序) - Microsoft Visual Studio 2017安装程序项目(Microsoft的VS2017 Addon)

现在我在properties =>中创建了一个设置项目先决条件我选择了Visual C++ "14" Runtime Libraries (x64)Download prerequisites from the component vendor's web site

如果我现在开始创建setup.exe,我在目标计算机上安装先决条件时出错:The following packages could not be found:(没有列出单个软件包)。 日志文件:

    The following properties have been set:
    Property: [AdminUser] = true {boolean}
    Property: [InstallMode] = HomeSite {string}
    Property: [NTProductType] = 1 {int}
    Property: [ProcessorArchitecture] = AMD64 {string}
    Property: [VersionNT] = 10.0.0 {version}
    Running checks for package 'Visual C++ "14" Runtime Libraries (x64)', phase BuildList
    Running MsiProductCheck with ProductCode '{C99E2ADC-0347-336E-A603-F1992B09D582}'
    MsiQueryProductState returned '-1'
    Setting value '-1 {int}' for property 'VCRedistInstalled'
    The following properties have been set for package 'Visual C++ "14" Runtime Libraries (x64)':
    Property: [VCRedistInstalled] = -1 {int}
    Running checks for command 'vc_redist.x64.exe'
    Result of running operator 'ValueGreaterThanEqualTo' on property 'VCRedistInstalled' and value '3': false
    Result of running operator 'ValueEqualTo' on property 'AdminUser' and value 'false': false
    Result of running operator 'ValueNotEqualTo' on property 'ProcessorArchitecture' and value 'AMD64': false
    Result of running operator 'VersionLessThan' on property 'VersionNT' and value '6.00': false
    Result of checks for command 'vc_redist.x64.exe' is 'Install'
    'Visual C++ "14" Runtime Libraries (x64)' RunCheck result: Install Needed
    Installation of components 'Visual C++ "14" Runtime Libraries (x64)' was accepted.
    Copying files to temporary directory "C:\Users\blubb_user\AppData\Local\Temp\VSD1A14.tmp\"
    Error: The following package files could not be found:

在VS 2015中我遇到了同样的麻烦。修复了在bootstrapp文件中修复PublicKey的问题。但我无法找到正确的PublicKey。我正在尝试使用匹配安装程序签名的PublicKey。在提到C:\Program Files (x86)\Microsoft SDKs\ClickOnce Bootstrapper\Packages\vcredist_x64\product.xml GUID C99E2ADC-0347-336E-A603-F1992B09D582时,我在C:\ProgramData\Package Cache\中查找了此GUID的设置并使用了此PublicKey。

知道如何为VS2017修复它吗?

更新(解决方案):

我能够为我修复它(VS2017 Update 7): 在packages.xml(C:\ Program Files(x86)\ Microsoft SDKs \ ClickOnce Bootstrapper \ Packages \ vcredist_x64 \ en)中,VCRedistExe的路径无效。 而不是

<String Name="VCRedistExe">https://aka.ms/vs/15/release/26405.00/VC_Redist.x64.exe</String>

我现在

<String Name="VCRedistExe">https://aka.ms/vs/15/release/26429.04/VC_Redist.x64.exe</String>

C:\ Program Files(x86)\ Microsoft SDKs \ ClickOnce Bootstrapper \ Packages \ vcredist_x64 \ product.xml我也改了      

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

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

    <InstallChecks>
        <MsiProductCheck Property="VCRedistInstalled" Product="{03EBF679-E886-38AD-8E70-28658449F7F9}"/>
    </InstallChecks>

    <!-- Defines how to invoke the setup for the Visual C++ 14.0 redist -->
    <Commands Reboot="Defer">
        <Command PackageFile="vc_redist.x64.exe" Arguments=' /q '>

            <!-- 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" Compare="ValueNotEqualTo" Value="AMD64" 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>

我不确定Product="{03EBF679-E886-38AD-8E70-28658449F7F9}",因为安装程序有GUID {80586c77-db42-44bb-bfc8-7aebbb220c00}(MsiProductCheck无法使用它),所以我从Microsoft Visual C ++ 2017 x64最小运行时间 - 14.14获取GUID。 26429。另一种可能性是使用Microsoft Visual C ++ 2017 x64附加运行时的GUID - 14.14.26429({B12F584A-DE7A-3EE3-8EC4-8A64DBC0F2A7})。最小和额外的运行时将与上面的脚本一起安装,因此我们采取的GUID并不重要。

3 个答案:

答案 0 :(得分:1)

我遇到了x86 redist的这个问题,最终能够责怪MS提供的所有 vcredist_x86 \ product.xml 文件。您应该能够将相同的修补程序应用于 vcredist_x64 \ product.xml 文件。 由于文件名和公钥与您从MS下载的实际redist文件不匹配而产生问题。

您必须将 PackageFiles \ PackageFile 节点和 product.xml Commands \ Command 节点中的名称更改为 vcredist_x64 .exe ,以及将redist包从MS重命名为 vcredist_x64.exe 。然后,更改 PackageFile 节点中的 publickey 属性,以匹配从MS获得的EXE的公钥。您可以通过使用文件资源管理器查看EXE的SHA1证书(属性 - &gt;数字签名(SHA1) - &gt;详细信息 - &gt;查看证书 - &gt;详细信息 - &gt;公钥)

答案 1 :(得分:0)

Same problem. Microsoft had a typo in their bootstrapper file. In C:\Program Files (x86)\Microsoft SDKs\ClickOnce Bootstrapper\Packages\vcredist_x86\product.xml

replace vcredist_x86.exe with vc_redist.x86.exe and reload Visual Studio.

答案 2 :(得分:0)

对于vs2015,vs2017,vs2019:我必须右键单击VC_redist.x86.exe文件上的属性,然后选择 Digital Signatures 标签,然后选择 sha256 (不是sha1),然后单击“详细信息”按钮以获取“证书属性”窗口,然后单击该窗口上的详细信息标签。然后,我必须向下滚动到公钥。在此,我必须从下面的ASCII转储窗口中选择并按Ctrl + C复制十六进制的公钥文本,因为复制到文件按钮仅创建.cer文件。然后,我必须在以管理员模式启动的Notepad ++中编辑 product.xml 文件,否则您将无法保存更新的文件。将公钥文本粘贴到product.xml文件后,我必须选择密钥的行,并用“”替换所有将十六进制数字隔开的空格。然后,我替换了 PublicKey 值并最终保存。 还有没有人觉得奇怪,在2020年vc_redist。*。exe文件的名称中仍然没有版本控制,下载站点没有在文本中指示版本,也没有指示公钥,因此知道自您上次下载以来已被更新的唯一方法是将文件大小与上一个版本进行比较?

更新2020-11-04:从https://support.microsoft.com/en-ca/help/2977003/the-latest-supported-visual-c-downloads下载最新的redist并如上所述更新product.xml之后,使用更新的msi安装我的应用程序时,出现错误,指出“以下软件包文件无法找到:vc_runtimeMinimum_x64.msi”。在将我今天下载的vc_redist exe与以前使用的exe进行比较时,我注意到它较小。看来我可以回到较旧的版本。