visual-studio - WiX:在组件传输期间保留递归目录结构
问题描述
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 只是提取我指定的文件并将它们放入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>
也许还检查:
推荐阅读
- html - 视频播放器控件越过导航栏
- javascript - NetSuite/SuiteScript 2.0 - 如何将新客户分配给支持案例
- node.js - Redis hGet 方法在异步调用时在第二次调用时陷入死锁
- installation - Wsadmin 连接到远程配置文件,ADMA0043E 异常
- php - 如何定义name=''值动态php?
- php - 您必须设置 php-http/httplug-bundle 以使用默认的 http 客户端服务 Symfony 4.2.4
- android - 有没有办法改变 Google Places 自动完成小部件的样式或行为?
- bigsql - 如何将子目录数据读入bigsql表?
- php - PHP 中的本地文件包含
- angular - Angular7 - 加载/更改组件时调用函数/API