Wix 安装位置错误地显示为命令行参数

Wix install location appearing incorrectly as command line argument

我正在尝试使用 wix 创建一个安装程序,我希望它的行为方式是在选择快捷方式时将安装文件传递给我的程序 args[],​​供其使用执行文件的路径。 但是,我添加了一些日志,并注意到由于某种原因它接收的路径是 "C:\Program"。即使我手动将参数设置为完整路径,我也无法让它看起来有所不同。这是 .wxs 文件的一些片段。

<!-- Define directory structure -->
    <Directory Id ="TARGETDIR" Name ="SourceDir">
        <Directory Id ="ProgramFilesFolder">
            <Directory Id ="MyAppsFolder" Name ="Applications">
                <Directory Id ="INSTALLFOLDER" Name ="MyApp">
                </Directory>
                <Directory Id ="ProgramMenuFolder">
                    <Directory Id ="ApplicationProgramsFolder" Name="Example Folder">
                        <Directory Id ="ShortcutFolder" Name ="MyApp">
                        </Directory>
                    </Directory>
                </Directory>
            </Directory>
        </Directory>
    </Directory>

<!-- Creating the shortcut -->
    <DirectoryRef Id ="ShortcutFolder">
        <Component Id ="ApplicationShortcut" Guid="{GUID_HERE}">
            <Shortcut Id ="RunMyApp"
                                Name ="MyApp"
                                Description ="Runs MyApp"
                                Target ="[INSTALLFOLDER]MyApp.exe"
                                WorkingDirectory ="INSTALLFOLDER"
                                Icon ="MyApp.ico"
                                Arguments ="[INSTALLFOLDER]FileToLoad.xml"/>

[INSTALLFOLDER] 似乎适用于除参数中的最后一行之外的所有其他内容。

提前致谢

我发现通过删除 [INSTALLFOLDER],它工作得很好。该行现在看起来像这样:

Arguments ="[INSTALLFOLDER]FileToLoad.xml"/>

我注意到这可能是因为工作目录已经设置为 INSTALLFOLDER,虽然我不确定。

这是众所周知的行为,WiX 不知道您的论点是什么,因此不会引用它们。请注意 [INSTALLFOLDER] 将在安装过程中扩展为(例如)c:\program files\your app,就像您使用此语法从命令行执行应用程序一样:

MyApp c:\program files\your app

请注意,您的应用程序将具有 { "c:\program", "files\your", "app" }

只需明确引用您的路径:

<Shortcut Id ="RunMyApp"
    Name ="MyApp"
    Description ="Runs MyApp"
    Target ="[INSTALLFOLDER]MyApp.exe"
    WorkingDirectory ="INSTALLFOLDER"
    Icon ="MyApp.ico"
    Arguments ="&quot;[INSTALLFOLDER]FileToLoad.xml&quot;"/>

它会导致 "c:\program files\your app\FileToLoad.xml" 并且命令行解析器会将其识别为单个参数。注意&quot;字符实体参考,完整列表可参考List of XML and HTML character entity references.