【问题标题】:How passing installationpath as parameter to a MSI file made with WIX如何将安装路径作为参数传递给使用 WIX 制作的 MSI 文件
【发布时间】:2014-09-18 12:46:42
【问题描述】:

我使用 Windows Installer XML 生成了一个 MSI 文件,并且选择的对话框集是“WixUI_Advanced”。 然后我想通过单击按钮并将安装路径作为参数传递给 MSI 从 WPF 窗口启动该 MSI。 所以我使用下面的代码来启动 MSI:

Process proc = new Process();
   proc.StartInfo.FileName = "msiexec";
   string filePath = "C:\\experimente\\WpfTestApplication\\TestSetup\\bin\\Debug\\TestSetup.msi";
   proc.StartInfo.Arguments = @"/i " + filePath + " INSTALLATIONPATH=C:\\workspace";
   proc.Start();

在 WIX-Project 的 Product.wxs 中,我定义了属性 INSTALLATIONPATH:

C:\安装

稍后我尝试在通常代表“ProgramFilesFolder”的 Id 中设置给定参数:

    <Directory Id="TARGETDIR"
               Name="SourceDir">
        <Directory Id="INSTALLATIONPATH">
            <Directory Id="APPLICATIONFOLDER"
                       Name="TestApplication">
            </Directory>
        </Directory>
    </Directory>

当我启动我的 WPF 应用程序并按下按钮时,MSI 启动,但安装路径仍然是程序文件文件夹。 谁能告诉我,我做错了什么?

提前致谢, 帕特里克

【问题讨论】:

    标签: c# wpf wix


    【解决方案1】:

    这很简单——如果你知道的话!

    您需要 - 在您的 MSI 项目和您的应用程序旁边 - 一个名为 p.e. 的引导程序项目。 “引导程序设置”。 在 Bundle.wxs 你写:

    <?xml version="1.0" encoding="UTF-8"?>
    <Wix xmlns="http://schemas.microsoft.com/wix/2006/wi"
         xmlns:bal="http://schemas.microsoft.com/wix/BalExtension">
        <Bundle Name="ProsoftSetupForTest" Version="1.0.0.0" Manufacturer="prosoft GmbH" UpgradeCode="b6f80b17-7a36-425c-a1e5-9c9e7e500da2">
            <BootstrapperApplicationRef Id="WixStandardBootstrapperApplication.RtfLicense" />
    
            <Variable Name="INSTALLFOLDER"
                      bal:Overridable="yes"
                      Type="string"
                      Value="[ProgramFilesFolder]"/>
    
            <Chain>
                <MsiPackage Vital="yes"
                            DisplayName="<The setup identifier for the program registry>"
                            Id="MsiId"
                            SourceFile="<The path of Your MSI">
                    <MsiProperty Name="TARGETDIR"
                                 Value="[INSTALLFOLDER]\MyFolder" />
                </MsiPackage>
            </Chain>
        </Bundle>
    </Wix>
    

    在您的 MSI 的 Product.wxs 中,您有一个 TARGETDIR 条目,如下所示:

    <Directory Id="TARGETDIR"
        Name="SourceDir">
    </Directory>
    

    然后你重建你的解决方案,在 Windows 资源管理器中进入你的引导程序项目的 Debug 文件夹,启动一个 DOS 窗口并设置如下命令:

    BootstrapperSetup.exe INSTALLFOLDER=C:\TestInstallation
    

    就是这样!

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-12-02
      • 2023-04-08
      • 2019-08-30
      • 1970-01-01
      • 1970-01-01
      • 2013-01-25
      相关资源
      最近更新 更多