如何使用wix安装程序到自定义文件夹,而不是Program Files文件夹

5

我使用wix创建了一个安装程序。默认情况下,该应用程序会安装在Program Files文件夹下。我需要在c:目录下创建一个文件夹,并将我的应用程序安装在其中。

<Fragment>
      <Directory Id="TARGETDIR" Name="SourceDir">
  <Directory Id="WINDOWSVOLUME" >
    <Directory Id="INSTALLLOCATION" Name="WIXDemoApp">
    </Directory>
  </Directory>
</Directory>

<SetDirectory Id="WINDOWSVOLUME" Value="c"/>

<Fragment>
    <ComponentGroup Id="ProductComponents" Directory="INSTALLFOLDER">

        <!-- TODO: Remove the comments around this Component element and the ComponentRef below in order to add resources to this installer. -->
         <Component Id="MyApplication.exe">
     <File Source="$(var.MyApplication.TargetPath)" Name="MyApp.exe" Id="MYAPPEXE" KeyPath="yes"  />
            <!-- TODO: Insert files, registry keys, and other resources here. -->
         </Component> 
    </ComponentGroup>
</Fragment>

我遇到了以下错误 "error LGHT0094: 在片段 'Fragment' 中未解析符号 'Directory:INSTALLFOLDER'"。

更新:

<Fragment>
          <Directory Id="TARGETDIR" Name="SourceDir">
      <Directory Id="WindowsVolume" >
        <Directory Id="INSTALLLOCATION" Name="WIXDemoApp">
        </Directory>
      </Directory>
    </Directory>

    <SetDirectory Id="WindowsVolume" Value="c"/>
  </Fragment>

    <Fragment>
        <ComponentGroup Id="ProductComponents" Directory="INSTALLLOCATION">

            <!-- TODO: Remove the comments around this Component element and the ComponentRef below in order to add resources to this installer. -->
             <Component Id="MyApplication.exe">
         <File Source="$(var.MyApplication.TargetPath)" Name="MyApp.exe" Id="MYAPPEXE" KeyPath="yes"  />
                <!-- TODO: Insert files, registry keys, and other resources here. -->
             </Component> 
        </ComponentGroup>
    </Fragment>

这给我带来了另一个错误"error LGHT0204: ICE99: 目录名称:WindowsVolume与MSI公共属性之一相同,可能会导致意想不到的副作用。"。我在Google上搜索并参考了这个这个来解决问题。但对我来说没有用,仍然出现相同的错误:"error LGHT0204: ICE99: 目录名称:WindowsVolume与MSI公共属性之一相同,可能会导致意想不到的副作用。"。有什么想法是什么问题呢?


你是否计划进行无人值守安装? - Black Frog
2个回答

5
我在kentie.net - Wix Tips & Tricks上找到了这个技巧。建议使用WINDOWSVOLUME id。

TARGETDIR和系统分区

尝试将安装目录设置为系统驱动器根目录下的子目录(例如'C:\ application'),可能有必要假设类似于以下内容:

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

TARGETDIR 指的是系统分区,而 ProgramFilesFolder 则总是作为 TARGETDIR 的子项给出。但实际情况并非如此;TARGETDIR 是具有最多可用磁盘空间的分区。它甚至可以是外部硬盘驱动器上的分区。要将其设置为真正的系统分区,请使用以下方法:

<Directory Id="TARGETDIR" Name="SourceDir">
    <Directory Id="WINDOWSVOLUME" >
        <Directory Id="INSTALLLOCATION" Name="SetupProject1">
        </Directory>
    </Directory>
 </Directory>

<SetDirectory Id="WINDOWSVOLUME" Value="[WindowsVolume]"/> 

需要使用 SetDirectory 元素,直接使用 WindowsVolume 会导致错误 LGHT0204: ICE99:目录名称 WindowsVolume 与 MSI 的公共属性之一相同,可能会引起意外的副作用。签署 MSIs。


1
这种方法对我来说完美地运行了,它没有显示 LGHT0204: ICE99 错误。 - Aebsubis
很高兴答案对您有所帮助。 - Black Frog

5

Windows Installer 是区分大小写的,所以 WINDOWSVOLUME 不起作用。您可以尝试以下方法:

<Fragment>
  <Directory Id="TARGETDIR" Name="SourceDir">
    <Directory Id="ProgramFilesFolder">
      <Directory Id="INSTALLLOCATION" Name="SetupProject1" />
    </Directory>
  </Directory>

  <SetDirectory Id="INSTALLLOCATION" Value="[WindowsVolume]SetupProject1" />
</Fragment>

对于你的第二个错误,你混淆了两个不同的id:INSTALLFOLDERINSTALLLOCATION。选择一个并在两个地方都使用它。

我已经更新了问题。我遇到了这个错误:“error LGHT0204: ICE99: 目录名称:WindowsVolume 与 MSI 公共属性之一相同,可能会导致意想不到的副作用。”。请查看我的问题中的“更新”。 - Royal

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接