WiX:在组件传输期间保留递归目录结构
WiX: preserving recursive directory structure during component transfer
Wix 3.11.2 和 Visual Studio 社区 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 只是提取我指定的文件并将它们放入 MyApp
目录,与 EXE 文件处于同一级别。我不想要这个;我想保留与我的 VS 项目中存在的相同的递归目录结构。因此,我希望 WiX MSI 生成的不是上面的:
C:\Program Files (x86)\
MyApp\
testo\
fizz\
abc\
def\
ghi\
abba.txt
foo.txt
my-app.exe
完成此操作的最简单方法是什么?
谢谢!
您需要嵌套文件夹,如本示例所示(向底部):https://www.codeproject.com/Tips/105638/A-quick-introduction-Create-an-MSI-installer-with
插图:
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="ProgramFilesFolder">
<Directory Id="INSTALLDIR" Name="Example">
<Component>
<File Source="example.exe"/>
</Component>
</Directory>
</Directory>
</Directory>
也许还要检查:
- My WiX Quick-Start Link Collection.
- https://www.firegiant.com/wix/tutorial/
Wix 3.11.2 和 Visual Studio 社区 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 只是提取我指定的文件并将它们放入 MyApp
目录,与 EXE 文件处于同一级别。我不想要这个;我想保留与我的 VS 项目中存在的相同的递归目录结构。因此,我希望 WiX MSI 生成的不是上面的:
C:\Program Files (x86)\
MyApp\
testo\
fizz\
abc\
def\
ghi\
abba.txt
foo.txt
my-app.exe
完成此操作的最简单方法是什么?
谢谢!
您需要嵌套文件夹,如本示例所示(向底部):https://www.codeproject.com/Tips/105638/A-quick-introduction-Create-an-MSI-installer-with
插图:
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="ProgramFilesFolder">
<Directory Id="INSTALLDIR" Name="Example">
<Component>
<File Source="example.exe"/>
</Component>
</Directory>
</Directory>
</Directory>
也许还要检查:
- My WiX Quick-Start Link Collection.
- https://www.firegiant.com/wix/tutorial/