Wix 工具集 - 如何将文件安装到完全不同的目录而不是作为根子目录?
Wix Toolset - how to install a file to a completely different directory and not as a root subdirectory?
对于我的应用程序,大部分文件需要安装到 ProgramFiles 中的一个目录,另外一个文件需要安装到 AppData/Local.
中的一个目录中
这是我目前所拥有的示例:
<Fragment>
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="ProgramFilesFolder">
<Directory Id="INSTALLFOLDER" Name="Folder1" />
</Directory>
</Directory>
</Fragment>
<Fragment>
<ComponentGroup Id="AppID" Directory="INSTALLFOLDER">
<Component Id="AppID">
<File Source="$(var.myApp.TargetPath)" />
</Component>
<Component Id="OtherFile" Guid="INSERT-GUID_HERE">
<File Id='OtherFile' Name='OtherFile' Source="otherfile" KeyPath='yes' />
</Component>
<Component Id="CopyId">
<CopyFile Id="CopyId" FileId="OtherFile"
DestinationDirectory="LocalAppDataFolder" />
</Component>
</Fragment>
我试图将另一个文件复制到 AppData/Local,但这不会编译并给出错误:
Unresolved reference to symbol 'Directory:LocalAppDataFolder' in section 'Fragment:'
理想情况下,我希望其他文件位于 AppData/Local 中的目录中,而不是在 ProgramFiles 中。
应用程序启动:考虑在应用程序启动时进行文件复制,而不是作为设置的一部分。根据需要更容易实施、调试和更改。
Fix:尝试将其直接添加到 TARGETDIR 元素下。这确保标准目录 LocalAppDataFolder
是已编译 MSI 文件目录 table:
的一部分
<Directory Id="LocalAppDataFolder" Name="AppData">
或者,这是一个更大的模型:
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="ProgramFilesFolder">
<Directory Id="INSTALLFOLDER" Name="SetupProject2" />
</Directory>
<Directory Id="LocalAppDataFolder" Name="AppData">
<Directory Id="AppRootDirectory" Name="MyApplication">
<Component Id="Test" Feature="ProductFeature" Guid="{11111111-1111-1111-1111-A73067A1AE95}">
<RemoveFolder Id="AppRootDirectory" On="uninstall" />
<RegistryValue Root="HKCU" Key="Software\Something" Name="Flag" Type="integer" Value="1" KeyPath="yes"/>
</Component>
</Directory>
</Directory>
</Directory>
对于我的应用程序,大部分文件需要安装到 ProgramFiles 中的一个目录,另外一个文件需要安装到 AppData/Local.
中的一个目录中这是我目前所拥有的示例:
<Fragment>
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="ProgramFilesFolder">
<Directory Id="INSTALLFOLDER" Name="Folder1" />
</Directory>
</Directory>
</Fragment>
<Fragment>
<ComponentGroup Id="AppID" Directory="INSTALLFOLDER">
<Component Id="AppID">
<File Source="$(var.myApp.TargetPath)" />
</Component>
<Component Id="OtherFile" Guid="INSERT-GUID_HERE">
<File Id='OtherFile' Name='OtherFile' Source="otherfile" KeyPath='yes' />
</Component>
<Component Id="CopyId">
<CopyFile Id="CopyId" FileId="OtherFile"
DestinationDirectory="LocalAppDataFolder" />
</Component>
</Fragment>
我试图将另一个文件复制到 AppData/Local,但这不会编译并给出错误:
Unresolved reference to symbol 'Directory:LocalAppDataFolder' in section 'Fragment:'
理想情况下,我希望其他文件位于 AppData/Local 中的目录中,而不是在 ProgramFiles 中。
应用程序启动:考虑在应用程序启动时进行文件复制,而不是作为设置的一部分。根据需要更容易实施、调试和更改。
Fix:尝试将其直接添加到 TARGETDIR 元素下。这确保标准目录 LocalAppDataFolder
是已编译 MSI 文件目录 table:
<Directory Id="LocalAppDataFolder" Name="AppData">
或者,这是一个更大的模型:
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="ProgramFilesFolder">
<Directory Id="INSTALLFOLDER" Name="SetupProject2" />
</Directory>
<Directory Id="LocalAppDataFolder" Name="AppData">
<Directory Id="AppRootDirectory" Name="MyApplication">
<Component Id="Test" Feature="ProductFeature" Guid="{11111111-1111-1111-1111-A73067A1AE95}">
<RemoveFolder Id="AppRootDirectory" On="uninstall" />
<RegistryValue Root="HKCU" Key="Software\Something" Name="Flag" Type="integer" Value="1" KeyPath="yes"/>
</Component>
</Directory>
</Directory>
</Directory>