如何使用除Program Files文件夹之外的wix安装程序在自定义文件夹中安装应用程序

时间:2014-11-18 12:38:42

标签: c# visual-studio-2010 visual-studio c#-4.0 wix

我使用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: Unresolved reference to symbol 'Directory:INSTALLFOLDER' in section 'Fragment:'”。

更新

<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: The directory name: WindowsVolume is the same as one of the MSI Public Properties and can cause unforeseen side effects.“。用Google搜索并审核thisthis来解决这个问题。但是没有为我工作,我仍然得到与”错误相同的错误LGHT0204:ICE99:目录名称:WindowsVolume与其中一个MSI公共属性相同,可能会导致无法预料的副作用。“。任何想法会出现什么问题。

2 个答案:

答案 0 :(得分: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。选择一个并在两个地方使用它。

答案 1 :(得分:3)

我在kentie.net - Wix Tips & Tricks找到了这个提示。提示说要使用 WINDOWSVOLUME id。

  

TARGETDIR和系统分区

     

尝试安装到系统驱动器根目录的子目录时   (例如&#39; C:\ application&#39;),可能会认为在某事物中   像

<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公共属性相同,可能会导致无法预料的副作用。   签署MSI