我正在为我想要安装的软件包编写WXS文件.为了简单起见,假设我想安装1个文件然后我想对它执行一个命令(在我的例子中,它是一个公共GPG密钥,我想在安装完成后导入它).以下是我的WXS文件的相关部分:
<CustomAction Id="ImportKey" Directory="INSTALLDIR"
ExeCommand="[SystemFolder]cmd.exe /C gpg --import keyfile.key"
Return="check" />
<!-- Install file keyfile.key into C:\GnuPG -->
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="INSTALLDIR" Name="GnuPG">
<Component Id="GnuPGConfiguration" Guid="E9469F1C-A875-1014-A3B3-DEF3264B13C4">
<File Name="keyfile.key" Id="KeyfileKey" />
</Component>
</Directory>
</Directory>
<Feature Id="GnuPGConfiguration" Level="1" Title="GnuPG Configuration">
<ComponentRef Id="GnuPGConfiguration" />
</Feature>
<!-- Run custom action after files are installed -->
<InstallExecuteSequence>
<Custom Action="ImportKey" After="InstallFiles">NOT Installed AND NOT PATCH</Custom>
</InstallExecuteSequence>
Run Code Online (Sandbox Code Playgroud)
我可以成功构建MSI.安装时,我使用msiexec并打开日志记录.它说安装在自定义操作上失败,并在日志中找到正确的命令.手动运行它.如果我注释掉命令的执行,则文件安装在正确的位置(安装后存在C:\ GnuPG\keyfile.key).
我尝试运行dir ant将其输出重定向到文件,而不是运行我的GPG命令.查看它,我可以看到keyfile.key不在C:\ GnuPG中的文件中.似乎该命令在安装文件之前运行.
关于我做错了什么的任何想法?
你需要阅读和理解:
Windows Installer中自定义操作的安装阶段和脚本执行选项
你会发现自己在考虑需要
<CustomAction ... Execute="deferred" and Impersonate="no" ... />
Run Code Online (Sandbox Code Playgroud)
此外,您可能需要限定.key文件的位置,因为您当前的目录不会像您认为的那样.
| 归档时间: |
|
| 查看次数: |
1773 次 |
| 最近记录: |