简体   繁体   English

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

[英]How to install application in custom folder using wix installer,other than Program Files folder

I have created an installer using wix. 我使用wix创建了一个安装程序。 By default the application gets installed under Program Files folder.I need to create a folder for my application under c: directory and install my application inside there. 默认情况下,应用程序安装在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>

I am getting the following error " error LGHT0094: Unresolved reference to symbol 'Directory:INSTALLFOLDER' in section 'Fragment:' ". 我收到以下错误“ error LGHT0094: Unresolved reference to symbol 'Directory:INSTALLFOLDER' in section 'Fragment:' ”。

Update: 更新:

<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>

This is giving me another error "error LGHT0204: ICE99: The directory name: WindowsVolume is the same as one of the MSI Public Properties and can cause unforeseen side effects. ".Googled and refereed this and this to fix this.But not working for me,still i am getting the same error as "error LGHT0204: ICE99: The directory name: WindowsVolume is the same as one of the MSI Public Properties and can cause unforeseen side effects.".Any idea what would be the problem. 这给了我另一个错误"error LGHT0204: ICE99: The directory name: WindowsVolume is the same as one of the MSI Public Properties and can cause unforeseen side effects."error LGHT0204: ICE99: The directory name: WindowsVolume is the same as one of the MSI Public Properties and can cause unforeseen side effects.搜索并审阅并解决问题。但不适用于我,仍然得到与“错误LGHT0204:ICE99:目录名称:WindowsVolume与MSI公共属性之一相同并且可能导致无法预料的副作用相同的错误。”。任何想法会出现什么问题。

Windows Installer is case-sensitive so WINDOWSVOLUME won't work. Windows Installer区分大小写,因此WINDOWSVOLUME不起作用。 You can do something like this: 你可以这样做:

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

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

For your second error, you're mixing two different ids: INSTALLFOLDER and INSTALLLOCATION . 对于第二个错误,您混合了两个不同的ID: INSTALLFOLDERINSTALLLOCATION Pick one and use it in both places. 选择一个并在两个地方使用它。

I found this tip on kentie.net - Wix Tips & Tricks . 我在kentie.net上找到了这个提示- Wix提示和技巧 Tips said to use the WINDOWSVOLUME id. 提示说要使用WINDOWSVOLUME id。

TARGETDIR and the system partition TARGETDIR和系统分区

When trying to install to a subdirectory of the system drive root (eg 'C:\\application'), it might sense to assume that in something like 当尝试安装到系统驱动器根目录的子目录(例如'C:\\ application')时,可能会认为在类似的东西中

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

TARGETDIR refers to the system partition, as ProgramFilesFolder is always given as a child of TARGETDIR. TARGETDIR指的是系统分区,因为ProgramFilesFolder总是作为TARGETDIR的子节点给出。 This is not the case; 不是这种情况; TARGETDIR is the partition with the most free disk space. TARGETDIR是具有最多可用磁盘空间的分区。 It can even be a partition on an external hard drive. 它甚至可以是外部硬盘驱动器上的分区。 To set it to the true system partition, use the below approach: 要将其设置为真正的系统分区,请使用以下方法:

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

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

The SetDirectory element is required as trying to use WindowsVolume directly results in 尝试使用WindowsVolume直接导致需要SetDirectory元素

error LGHT0204: ICE99: The directory name: WindowsVolume is the same as one of the MSI Public Properties and can cause unforeseen side effects. 错误LGHT0204:ICE99:目录名称:WindowsVolume与其中一个MSI公共属性相同,可能会导致无法预料的副作用。 Signing MSIs 签署MSI

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM