c# - 如何使用 wix 安装程序在自定义文件夹中安装应用程序,而不是 Program Files 文件夹

标签 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:未解析对‘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: The directory name: WindowsVolume is the same as one of the MSI Public Properties and can cause unforeseen side effects.”。谷歌搜索并引用 thisthis 来解决这个问题。但对我不起作用,我仍然收到与“错误 LGHT0204:ICE99:目录名称:WindowsVolume 与 MSI 公共(public)属性之一相同并且可能导致无法预料的副作用。”的错误。知道会出现什么问题。

最佳答案

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。选择一个并在两个地方使用它。

关于c# - 如何使用 wix 安装程序在自定义文件夹中安装应用程序,而不是 Program Files 文件夹,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26994571/

相关文章:

c++ - 重建预编译头文件

c++ - Visual Studio C++ 编译器中的错误?

c# - 如何在 c# 中调用此 c 函数(解码返回结构)?

c# - 发送时无法立即完成非阻塞套接字操作

visual-studio-2010 - Visual Studio 2010 日志文件

c++ - 在 Visual Studio 2010 中将仿函数传递给 boost::thread 失败

python - Visual Studio Tools for AI - 未加载变量资源管理器

c# - 将 WPF 视觉对象渲染为图像产生纯黑色图像

c# - 通过 Azure 函数显示 Azure Blob 存储中的文件

c++ - 强名称 dll - 如何排除故障?