带有用户输入的 WIX 设置

WIX setup with user input

我已经为 WIX 苦苦挣扎了一段时间。我想让我的程序安装在用户定义的位置,安装一个服务,安装后启动一个程序。

首先我的 msi 包不要求安装路径。

<Fragment>
<Directory Id="TARGETDIR" Name="SourceDir">
  <Directory Id="ProgramFilesFolder">
    <Directory Id="INSTALLFOLDER" Name="Test" />
  </Directory>
</Directory>
</Fragment>

有人可以告诉我如何提示屏幕更改安装路径吗?

第二次安装我的服务时出现错误,提示我缺少某些权限:

<File Id="FILE_Service" Source="$(var.Service.TargetPath)" />
    <ServiceInstall Id="INSTALL_Service"
                    Name="Servcie"
                    Description=""
                    Start="auto"
                    ErrorControl="normal"
                    Type="ownProcess"/>

    <ServiceControl Id="CONTROL_Service"
                          Name="Servcie"
                          Start="install"
                          Stop="both"
                          Remove="uninstall"
                          Wait="yes" />

有人可以告诉我如何使用管理员权限启动我的服务吗?

第三个安装包只包含一个EXE文件,没有引用程序集。有人可以告诉我如何告诉 WIX 搜索参考并安装它们吗?

WiX 教程:这里有很多。您应该尝试 WiX 教程:https://www.firegiant.com/wix/tutorial/

链接:这是我的 WiX quick start tip answer - 处理 WiX 和一般部署的各种资源和提示。

请注意,如果您对 MSI 和设置经验不多,there are alternative deployment and package creation tools 可能会帮助您更快、更可靠地进行设置。


具体答案:以下是针对您的具体问题的一些尝试答案:

  • Configurable installation directory (a bit down the page). You essentially set the ConfigurableDirectory attribute for a feature element to allow the user to select a custom installation directory (you get to the dialog where you can change the installation path by selecting "Custom" installation):

    <Feature Id="FeatureDirectory" Title="FeatureDirectory" ConfigurableDirectory="MYCUSTOMDIR">
         <!-- your stuff here -->
    </Feature>
    
  • 重大升级安装目录:重大升级需要回读自定义目录。方法如下:The WiX toolset's "Remember Property" pattern。否则它将在主要升级期间恢复为默认值。这是因为主要升级是卸载旧版本并(重新)安装新版本。

  • Files:要安装所有需要的文件,你需要通过依赖扫描找出需要的文件为您的应用程序部署工作,然后手动将它们添加到您的包中(或使用 heat.exe 自动生成要包含的文件列表)。请参阅上面的快速入门链接以获取帮助,或查看这篇 hello wix 风格的文章:https://www.codeproject.com/Tips/105638/A-quick-introduction-Create-an-MSI-installer-with

  • 服务权限:如果您在 UAC 提升提示后安装安装程序,则应使用管理员权限安装服务.它很可能没有启动,因为缺少文件并因此破坏了依赖关系。该服务使用什么凭据 运行?本地系统?


Mock-Up:这是根据您的需要快速制作的模型。您需要添加所有文件和依赖项并插入服务结构等:

<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
  <Product Id="*" Name="WiXSample" Language="1033" Version="1.0.0.0"
           Manufacturer="Someone" UpgradeCode="cb24bedf-e361-4f25-9a06-ac84ce5d6f5c">
    <Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine" />

    <MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." />
    <MediaTemplate EmbedCab="yes" />

    <!--Default GUI - add reference to WixUIExtension.dll -->
    <UIRef Id="WixUI_Mondo" />

    <Feature Id="Core" Title="Core" Level="1" ConfigurableDirectory="INSTALLFOLDER" />

    <Directory Id="TARGETDIR" Name="SourceDir">
      <Directory Id="ProgramFilesFolder">
        <Directory Id="INSTALLFOLDER" Name="WiXSample">
          <Component Feature="Core">
            <File Source="D:\MyBinary.exe" />
          </Component>
        </Directory>
      </Directory>
    </Directory>
  </Product>

</Wix>