【发布时间】:2019-12-30 20:26:35
【问题描述】:
Wix 3.11.2 和 Visual Studio Community 2019 在这里。我的项目目录结构如下:
...\Source\Repos\my-app-setup\
my-app-setup\
bin\
obj\
testo\
fizz\
abc\
def\
ghi\
abba.txt
buzz\
bar.txt
foo.txt
my-app.exe
my-app-setup.wixproj
my-app-setup.wxs
my-app-setup.sln
我的my-app-setup.wxs文件如下:
<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Product Id="*" Name="MyApp" Language="1033" Version="1.0.0.0" Manufacturer="MyCompany" UpgradeCode="1e540666-dda2-4cbe-91b7-ac9525d96c86">
<Package Description="MyApp tool" Compressed="yes" />
<MediaTemplate EmbedCab="yes"/>
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="ProgramFilesFolder">
<Directory Id="INSTALLFOLDER" Name="MyApp" />
</Directory>
<Directory Id="DesktopFolder" Name="Desktop">
<Component Id="ApplicationShortcutDesktop" Guid="*">
<Shortcut Id="ApplicationDesktopShortcut"
Name="MyApp"
Description="Shortcut for MyApp"
Target="[INSTALLFOLDER]my-app.exe"
WorkingDirectory="INSTALLFOLDER"/>
<RemoveFolder Id="DesktopFolder" On="uninstall"/>
<RegistryValue
Root="HKCU"
Key="Software/MyApp"
Name="installed"
Type="integer"
Value="1"
KeyPath="yes"/>
</Component>
</Directory>
</Directory>
<Component Id="FooTxtComponent" Directory="INSTALLFOLDER">
<File Source="testo/foo.txt" />
</Component>
<Component Id="AbbaComponent" Directory="INSTALLFOLDER">
<File Source="testo/fizz/abc/def/ghi/abba.txt" />
</Component>
<Component Id="ExecutableComponent" Directory="INSTALLFOLDER">
<File Source="my-app.exe" />
</Component>
<Feature Id="MainFeature" Title="MyApp" Level="1">
<ComponentRef Id="FooTxtComponent" />
<ComponentRef Id="AbbaComponent" />
<ComponentRef Id="ExecutableComponent" />
<ComponentRef Id="ApplicationShortcutDesktop" />
</Feature>
</Product>
</Wix>
所以它基本上只是将一堆文件从项目复制到C:\Program Files (x86)\MyApp 目录,然后在桌面上创建一个快捷方式(到 EXE)。简单的东西。
当我构建它并运行 MSI 时,生成的 C:\Program Files (x86)\MyApp 目录如下所示:
C:\Program Files (x86)\
MyApp\
foo.txt
abba.txt
my-app.exe
所以 WiX 只是提取我指定的文件并将它们放入与 EXE 文件相同级别的 MyApp 目录中。我不想要这个;我想保留与我的 VS 项目中存在的相同的递归目录结构。因此,我希望生成 WiX MSI 而不是上面的:
C:\Program Files (x86)\
MyApp\
testo\
fizz\
abc\
def\
ghi\
abba.txt
foo.txt
my-app.exe
最简单的方法是什么?
谢谢!
【问题讨论】:
-
如果你想要相同的文件夹结构,你应该在wix中手动完成,或者使用
heat工具自动生成
标签: visual-studio wix windows-installer