在 WIX 中执行自定义操作时未安装文件 [英] Files not installed when executing custom action in WIX

查看:24
本文介绍了在 WIX 中执行自定义操作时未安装文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为要安装的软件包编写 WXS 文件.为简单起见,假设我想安装 1 个文件,然后我想针对它执行一个命令(在我的例子中,它是一个公共 GPG 密钥,我想在安装完成后导入它).以下是我的 WXS 文件的相关部分:

I am writing a WXS file for a package I want to install. For the sake of simplicity, let's say I want to install 1 file and then I want to execute a command against it (in my case, it is a public GPG key and I want to import it after the installation is done). Here are the relevant parts of my WXS file:

<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>

我可以成功构建 MSI.安装时,我使用 msiexec 并打开日志记录.它说自定义操作上的安装失败,并且在日志中找到了正确的命令.手动运行它.如果我注释掉该命令的执行,则该文件安装在正确的位置(安装后存在 C:\GnuPG\keyfile.key).

I can successfully build the MSI. When installing, I use msiexec and turn on logging. There it says that installation fails on the custom action and the correct command is found in the log. Running it manually works. If I comment out execution of the command, the file is installed in the correct location (C:\GnuPG\keyfile.key exists after installation).

我没有运行我的 GPG 命令,而是尝试运行 dir ant 将其输出重定向到一个文件.查看它,我可以看到keyfile.key 不在C:\GnuPG 中的文件中.好像是在安装文件之前运行命令.

Instead of running my GPG command, I tried running dir ant redirected its output to a file. Viewing it, I can see that keyfile.key is not among the files in C:\GnuPG. It seems that the command is run before the file is installed.

对我做错了什么有任何想法吗?

Any ideas on what I am doing wrong?

推荐答案

你需要阅读和理解:

Windows Installer 中自定义操作的安装阶段和脚本内执行选项

你会发现自己正在考虑需要

You will find yourself considering needing

<CustomAction ... Execute="deferred" and Impersonate="no" ... />

此外,您可能需要限定 .key 文件的位置,因为您当前的目录不会是您认为的那样.

Also you are likely to need to qualify the location of the .key file as your current directory isn't going to be what you think it is.

这篇关于在 WIX 中执行自定义操作时未安装文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆