![](/img/trans.png)
[英]Can i use VS Setup Project to build a bootstrapper which can install correct platform version or are there any free 3rd party tools?
[英]Change install directory WIX Bootstrapper
我在自定義引導程序項目中替換WIX項目的安裝目錄時遇到麻煩。 該解決方案包括3個項目(自定義Bootstrapper,Installer項目和BootstrapperSetup)。
安裝程序項目中的product.wcs如下所示:
<?xml version="1.0" encoding="UTF-8"?>
<?include $(sys.CURRENTDIR)\Settings\settings.wxi ?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi"
xmlns:bal="http://schemas.microsoft.com/wix/BalExtension">
<Product Id="*" Name="$(var.ProductName)" Language="1033" Version="1.0.0.0" Manufacturer="$(var.Manufacturer)" UpgradeCode="f4c5c824-17e9-4897-9af0-49b2b1225251">
<Package InstallerVersion="300" Compressed="yes" InstallScope="perMachine" />
<MajorUpgrade DowngradeErrorMessage="A newer version of $(var.ProductName) is already installed." />
<MediaTemplate />
<Property Id="PRODUCTNAME" Value="$(var.ProductName)" />
<Property Id="INSTALL_LOCATION" Value="ApplicationInstallDir"/>
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="$(var.PlatformProgramFilesFolder)" Name="PFiles">
<Directory Id="DirManufacturer" Name="$(var.Manufacturer)">
<Directory Id="ApplicationInstallDir" Name="$(var.ProductName)">
<Component Id="ProductComponent" KeyPath="yes" Guid="28982BC3-BCEA-4EAF-9E7E-9E19A9355CFA">
<File Id="Norma12" Name="$(var.Norma 12.TargetFileName)" Source="$(var.Norma 12.TargetPath)" DiskId="1" />
<CreateFolder />
</Component>
</Directory>
</Directory>
</Directory>
</Directory>
<Feature Id="ProductFeature" Title="InstallerProject" Level="1">
<ComponentRef Id="ProductComponent" />
</Feature>
</Product>
</Wix>
bundle.wxs看起來像這樣:
<?xml version="1.0" encoding="UTF-8"?>
<?include $(sys.CURRENTDIR)\Settings\settings.wxi ?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi"
xmlns:util="http://schemas.microsoft.com/wix/UtilExtension"
xmlns:bal="http://schemas.microsoft.com/wix/BalExtension">
<Bundle Name="$(var.ApplicationName)" Version="$(var.Version)" Manufacturer="$(var.Manufacturer)"
UpgradeCode="ba657b0d-46d6-452a-aa4c-4212dda03d52"
Copyright="Copyright (c) 2013 $(var.Manufacturer). All rights reserved."
HelpUrl="http://www.miconsultancy.com" AboutUrl="http://www.miconsultancy.com">
<BootstrapperApplicationRef Id="ManagedBootstrapperApplicationHost">
<Payload SourceFile="$(var.MI Wix.TargetDir)\BootstrapperCore.config"/>
<Payload SourceFile="$(var.MI Wix.TargetPath)"/>
<Payload SourceFile="C:\Program Files (x86)\WiX Toolset v3.7\SDK\Microsoft.Deployment.WindowsInstaller.dll"/>
</BootstrapperApplicationRef>
<Variable Name="ProjectName" Type="string" Value="$(var.ApplicationName)" />
<Variable Name="LicenseRTF" Type="string" Value="$(var.MI Wix.ProjectDir)\License\mi_lic.rtf"/>
<Variable Name="ProductID" Type="string" Value="$(var.ApplicationID)"/>
<Variable Name="varInstallLocation" Type="string" Value="\$(var.Manufacturer)\$(var.ApplicationName)"/>
<Chain>
<!-- TODO: Define the list of chained packages. -->
<PackageGroupRef Id='Netfx4Full' />
<MsiPackage Compressed="yes"
SourceFile="$(var.InstallerProject.TargetPath)"
Vital="yes" Id="$(var.ApplicationID)" >
<MsiProperty Name="INSTALL_LOCATION" Value="[varInstallLocation]"/>
</MsiPackage>
</Chain>
</Bundle>
<Fragment>
<!-- Managed bootstrapper requires .NET as a dependency, since it was written in .NET.
WiX provides a Bootstrapper for the bootstrapper. The fragment below includes .NET.
For more information or examples see Heath Stewart's blog or the WiX source:
http://blogs.msdn.com/b/heaths/archive/2011/10/28/introducing-managed-bootstrapper-applications.aspx
-->
<WixVariable Id="WixMbaPrereqPackageId" Value="Netfx4Full" />
<WixVariable Id="WixMbaPrereqLicenseUrl" Value="NetfxLicense.rtf" />
<util:RegistrySearch Root="HKLM" Key="SOFTWARE\Microsoft\Net Framework Setup\NDP\v4\Full" Value="Version" Variable="Netfx4FullVersion" />
<util:RegistrySearch Root="HKLM" Key="SOFTWARE\Microsoft\Net Framework Setup\NDP\v4\Full" Value="Version" Variable="Netfx4x64FullVersion" Win64="yes" />
<PackageGroup Id="Netfx4Full">
<ExePackage Id="Netfx4Full" Cache="no" Compressed="yes" PerMachine="yes" Permanent="yes" Vital="yes"
SourceFile="C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bootstrapper\Packages\DotNetFX40\dotNetFx40_Full_x86_x64.exe"
DownloadUrl="http://go.microsoft.com/fwlink/?LinkId=164193"
DetectCondition="Netfx4FullVersion AND (NOT VersionNT64 OR Netfx4x64FullVersion)" />
</PackageGroup>
</Fragment>
</Wix>
需要在自定義引導程序中更改變量varInstallLocation ,方法是:
BootstrapperApplication.Engine.StringVariables("varInstallLocation") = s_installDirectory
但是,當我執行保存代碼時,新的安裝路徑不會存儲到變量中,並且該應用程序將安裝在默認位置。 有人可以幫我嗎。
確保在調用Engine.Apply()
之前設置了變量。 此后設置的變量將不會提供給鏈接包。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.