我已经使用 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.
”。谷歌搜索并引用 this和 this 来解决这个问题。但对我不起作用,我仍然收到与“错误 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:INSTALLFOLDER
和 INSTALLLOCATION
。选择一个并在两个地方使用它。
关于c# - 如何使用 wix 安装程序在自定义文件夹中安装应用程序,而不是 Program Files 文件夹,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26994571/