[英]How to include prerequisites with msi/Setup.exe in WIX
我正在嘗試將我的包組合在一個設置EXE文件中並將其上傳到Internet。
我創建了一個Microsoft引導程序,其中包含帶有項目MSI輸出的Setup.exe,以及必備的.NET Framework 2.0, Windows Installer 3.1, Visual C ++ 2005可再發行組件和Microsoft ReportViewer 。 我使用Visual Studio 2008創建了一個安裝項目。
現在我正在嘗試使用WiX 3.6創建單個壓縮設置。 我已經在Visual Studio 2008中安裝了它。
我使用以下命令附加了setup.exe和MSI文件。
<ExePackage SourceFile ="setup.exe" Compressed ="yes"/>
<MsiPackage SourceFile ="myproject.msi" Compressed ="yes" />
但它無法找到MSI文件。 我怎樣才能包含上述先決條件?
或者我可以在安裝時從Internet下載上述先決條件嗎? 我該怎么做?
我從Visual Studio中刪除了默認的setup.exe
,並使用Visual Studio中的MSI文件和依賴項創建了一個WiX 3.6 Bootstrapper:
<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi"
xmlns:bal="http://schemas.microsoft.com/wix/BalExtension"
xmlns:util="http://schemas.microsoft.com/wix/UtilExtension">
<Bundle Name="My Application"
Version="1.0"
IconSourceFile ="E:\logo.ico"
Manufacturer="My company"
UpgradeCode="4dcab09d-baba-4837-a913-1206e4c2e743">
<BootstrapperApplicationRef Id="WixStandardBootstrapperApplication.RtfLicense">
<bal:WixStandardBootstrapperApplication
LicenseFile="E:\License.rtf"
SuppressOptionsUI ="yes"
LogoFile ="logo.ico" />
</BootstrapperApplicationRef>
<Chain>
<ExePackage
SourceFile ="ReportViewer\ReportViewer.exe"
Compressed ="yes"
Vital ="no"
Permanent ="yes"/>
<ExePackage
SourceFile ="vcredist_x86\vcredist_x86.exe"
Compressed ="yes"
Vital ="no"
Permanent ="yes"/>
<MsiPackage
SourceFile ="MySetup.msi"
Compressed ="yes"
DisplayName ="My Application"
ForcePerMachine ="yes"/>
</Chain>
</Bundle>
</Wix>
它壓縮為具有先決條件的單個EXE文件。
SourceFile
將接受.msi文件的相對路徑。 或者,如果要使用WiX安裝項目構建.msi文件,則可以在WiX Bootstrapper項目中添加對安裝項目的引用。 它定義了你可以使用的變量 ,如下所示:
<MsiPackage SourceFile ="$(var.myproject.TargetPath)" Compressed ="yes" />
如果刪除Visual Studio Bootstrapper並將所有先決條件放在WiX Bootstrapper中,您的用戶可能會獲得更好的體驗。 對您而言,這將是一項更多的工作,因為沒有預先定義的ExePackageGroup
或ExePackage
用於您的所有項目的先決條件。
檢查有關ExePackage
定義內容的信息的最佳位置是有關特定先決條件的文檔。 但是,與Visual Studio Bootstrapper軟件包(例如, C:\\Program Files\\Microsoft Visual Studio 9\\SDK\\v2.0\\Bootstrapper\\Packages
)以及可能在WiX中預定義的類似先決條件進行比較也具有指導意義。源代碼。 特別是,在WiX源代碼中,您將找到一個ExePackage
,在安裝時根據需要從Internet下載.NET 4。
您可以包含一些先決條件文件,例如:
<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Product Id="*" Name="MyApplication" Version="$(var.ProductVersion)" Manufacturer="manuf" Language="1033">
[...]
<Directory Id="ANOTHERLOCATION" Name="MyApplicationName">
<Component Id="ApplicationFiles" Guid="12345678-1234-1234-1235-111111111111">
<File Id="ApplicationFile4" Source="C:\Users\user\Desktop\requisite.exe"/>
<CreateFolder />
</Component>
</Directory>
<SetDirectory Id="ANOTHERLOCATION" Value="[WindowsVolume]MyApp" />
<Feature Id="DefaultFeature" Level="1">
<ComponentRef Id="ApplicationFiles" />
</Feature>
</Product>
</Wix>
以上復制C:/ MyApp中的requisite.exe文件。 然后,您必須根據某些條件從程序中運行requisite.exe文件。 這是不使用復雜的Wix魔法的最基本和最直接的方式。
您可以使用類似NSIS的東西來包裝您的引導程序和MSI。 您需要編寫一個簡單的NSIS腳本,如下所示:
!define PRODUCT_NAME "YourProductNameHere"
Name "${PRODUCT_NAME}"
OutFile "SetupWrapper.exe"
Icon "Setup.ico"
BrandingText " "
SilentInstall silent
Section
SetOutPath "$TEMP\${PRODUCT_NAME}"
; Add all files that your installer needs here
File "setup.exe"
File "product.msi"
ExecWait "$TEMP\${PRODUCT_NAME}\setup.exe"
RMDir /r /REBOOTOK "$TEMP\${PRODUCT_NAME}"
SectionEnd
將其保存到名為SetupWrapper.nsi的文件中,並編輯setup.exe和MSI文件的產品名稱和路徑。 現在,您可以構建此文件以獲取包含引導程序和MSI的單個EXE文件。
運行此EXE時,它將沒有自己的任何UI - 它只會將您的引導程序和MSI提取到臨時文件夾,然后執行引導程序,然后進行清理。
您還可以在項目中添加一個構建后步驟來構建此包裝器,它將自動生成組合的包裝器EXE。 為此,您可以添加如下命令:
path-to-NSIS\nsis-2.46\makensis.exe /V2 your-project-path\SetupWrapper.nsi
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.