WiX是制作msi安装文件的工具,看了半天文档,感觉没有什么比一个例子更简单粗暴的了。
<?xml version="1.0" encoding="UTF-8"?> <Wix xmlns="http://schemas.microsoft.com/wix/2006/wi"> <Product Id="*" Name="HelloMSI" Language="1033" Version="1.0.0.0" Manufacturer="LEH" UpgradeCode="1de12ee7-2e94-42ac-979f-06245a0ade31"> <Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine" /> <Media Id="1" Cabinet="media1.cab" EmbedCab="yes" /> <Directory Id="TARGETDIR" Name="SourceDir"> <Directory Id="ProgramFilesFolder"> <Directory Id="INSTALLFOLDER" Name="HelloWorld"> <Component Id="ProductComponent" Guid="B5F0C012-49D6-4C63-AFCA-0CE6C24C6D7E"> <File Id="HelloWorld" Source="HelloWorld.exe" /> </Component> </Directory> </Directory> </Directory> <Feature Id="ProductFeature" Title="HelloWorld" Level="1"> <ComponentRef Id="ProductComponent" /> </Feature> <Property Id="WixShellExecTarget" Value="[#HelloWorld]" /> <CustomAction Id="LaunchFile" BinaryKey="WixCA" DllEntry="WixShellExec" Impersonate="yes"/> <InstallExecuteSequence> <Custom Action=‘LaunchFile‘ After=‘InstallFinalize‘>NOT Installed</Custom> </InstallExecuteSequence> </Product> </Wix>
将这段XML存为Product.wxs,记得是UTF-8编码,然后命令行下执行:
candle Product.wix light Product.wixobj -out HelloWorld.msi -ext WixUtilExtension msiexec /i HelloWorld.msi /qn
忘了说运行的前提:
- 安装WiX并将其加入PATH
- 命令行需要以管理员权限打开
- 将例子中的GUID也都换一下吧
刚才做的事情,其实就是:
- 将Helloworld.exe包装进msi安装文件Product.msi
- 然后静默安装Product.msi
- 安装完成后立即运行Helloworld.exe文件
[参考文献]
阿扁的“Wix学习整理”
WiX官网的“How To: Run the Installed Application After Setup”
StackOverflow的“Open readme.txt at end of installatin failed in WiX”
时间: 2024-10-05 12:23:00