【发布时间】:2017-09-12 07:57:46
【问题描述】:
我遵循了一个简单的 YouTube 说明视频,介绍了如何进行非常基本的 WiX 设置来创建 msi 文件。 目的是将某些文件放入某些目录并制作 4 个注册表项。我使用 VS 2015 中内置的安装项目做到了这一点,效果很好。然而,WiX 项目不起作用。这也是我第一次使用 XML。
例如,我在这里定义了目录:
<Fragment>
<Directory Id="ProgramFilesFolder" Name="Programfiles">
<Directory Id="MSOFFICEFOLDER" Name="Microsoft Office">
<Directory Id="OFFICE14FOLDER" Name="Office14" />
<Directory Id="LIBRARY" Name="Library">
<Directory Id="MAKRO" Name="Makro">
</Directory>
</Directory>
</Directory>
</Directory>
</Fragment>
这里我把文件放到文件夹里:
<!-- Adding files to Office14 folders -->
<Fragment>
<DirectoryRef Id="OFFICE14FOLDER">
<Component Id="umrch.hlp" Guid="*">
<File Id="umrch.hlp" Source="MySourceFiles\UMRCH.HLP" KeyPath="yes"
Checksum="yes"/>
</Component>
</DirectoryRef>
<DirectoryRef Id="LIBRARY">
<Component Id="umrch.xla" Guid="*">
<File Id="umrch.xla" Source="MySourceFiles\umrch.xla" KeyPath="yes"
Checksum="yes"/>
</Component>
</DirectoryRef>
<DirectoryRef Id="MAKRO">
<Component Id="umrch.xla" Guid="*">
<File Id="umrch.xla" Source="MySourceFiles\umrch.xla" KeyPath="yes"
Checksum="yes"/>
</Component>
</DirectoryRef>
<!-- Adding files to Company folders-->
<DirectoryRef Id="DATA">
<Component Id="DATAfiles" Guid="*">
<File Id="defumrch.dat" Source="MySourceFiles\defumrch.dat"
KeyPath="yes" Checksum="yes"/>
<File Id="LL_UMRCH.DAT" Source="MySourceFiles\LL_UMRCH.DAT"
KeyPath="no" Checksum="yes"/>
</Component>
</DirectoryRef>
<DirectoryRef Id="VERSION">
<Component Id="VERSIONfiles" Guid="*">
<File Id="umrch_Readme.doc" Source="MySourceFiles\umrch_Readme.doc"
KeyPath="yes" Checksum="yes"/>
<File Id="umrch_Version.txt" Source="MySourceFiles\umrch_Version.txt"
KeyPath="no" Checksum="yes"/>
</Component>
</DirectoryRef>
<!-- Adding files to Windows folder-->
<DirectoryRef Id="WindowsFolder">
<Component Id="WINDOWSfiles" Guid="">
<File Id="umrch.dll" Source="MySourceFiles\umrch.dll" KeyPath="yes"
Checksum="yes"/>
<File Id="umrch.lib" Source="MySourceFiles\umrch.lib" KeyPath="no"
Checksum="yes"/>
<File Id="umrch.mif" Source="MySourceFiles\umrch.mif" KeyPath="no"
Checksum="yes"/>
</Component>
</DirectoryRef>
</Fragment>
应该在这里安装它们:
<Fragment>
<!-- Tell WiX to install the files -->
<Feature Id="xlahelp" Title="XLA and help files" Level="1">
<ComponentRef Id="umrch.hlp" />
<ComponentRef Id="umrch.xla" />
</Feature>
<Feature Id="COMPANYfiles" Title="Company files" Level="1">
<ComponentRef Id="DATAfiles" />
<ComponentRef Id="VERSIONfiles" />
</Feature>
<Feature Id="WindowsFiles" Title="Windows files" Level="1">
<ComponentRef Id="WINDOWSfiles" />
</Feature>
<Feature Id="Registry" Title="umrch" Level="1">
<ComponentGroupRef Id="Registry"/>
</Feature>
</Fragment>
是否缺少一些参考资料或者我错误地使用了 XML?
编辑:这是产品 wix
<Product Id="*" Name="UMRCH" Language="1033" Version="1.0.0.0" Manufacturer="Sample" UpgradeCode="ee45fb60-6741-4424-8136-dfc0d679629a">
<Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine" />
<MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." />
<MediaTemplate />
</Product>
为 Stein Åsmul 编辑:
DATA 和 VERSION 应该在这里定义:
<Fragment>
<Directory Id="WindowsVolume" Name="WindowsVolume">
<Directory Id="!(bind.property.Manufacturer)" Name="!(bind.property.Manufacturer)">
<Directory Id="UMRCH" Name="!(bind.property.ProductName)" />
<Directory Id="DATA" Name="data">
<Directory Id="VERSION" Name="version" />
</Directory>
</Directory>
</Directory>
它在使用 WiX 时也可以编译。构建 .msi 文件时不会出现任何错误。 使用 SuperOrca 打开它时,它会显示一个选项卡 _Validation,因为我对此很陌生,但我不知道如何在 Orca 中读取 .msi。
我现在还在 github 上添加了一个 gist 以获得更好的可见性。
【问题讨论】:
-
你能提供定义你的
<Product>的wxs吗?如果您没有正确引用您制作的这些片段(最终在<Product>中引用),所有内容都将在编译时被丢弃。 -
我更新了我原来的帖子!
-
最好只显示您的整个 WiX 源代码,以便可以简单地复制和粘贴以供其他人复制。
-
我想我做到了,最后的链接提供了两个 .wxs 文件,这是我的解决方案中的全部内容。
标签: xml visual-studio-2015 wix windows-installer registry