在 WIX 中执行自定义操作时未安装文件

发布于 2024-09-24 08:11:56 字数 1325 浏览 0 评论 0原文

我正在为我想要安装的包编写 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>

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

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

关于我做错了什么有什么想法吗?

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>

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

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

夕色琉璃 2024-10-01 08:11:56

您需要阅读并理解:

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

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

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

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

You need to read and understand:

Installation Phases and In-Script Execution Options for Custom Actions in Windows Installer

You will find yourself considering needing

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

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文