问题描述
我想自动将文件夹C:\example\dir
添加到Wix Toolset MSI安装程序。
我这样使用HarvestDirectory target:
<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<?include "Config.wxi" ?>
<Product Id="*" Name="programName" Language="1033" Version="1.0.0.0" Manufacturer="Me" UpgradeCode="2275bf6b-489e-49f3-a7fd-cfd96ed94d7b">
<Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine" Platform="x64" />
<MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." />
<MediaTemplate EmbedCab="yes" />
<Feature Id="ProductFeature" Title="programName" Level="1">
<ComponentGroupRef Id="BinDirRefId" />
</Feature>
<UIRef Id="WixUI_InstallDir" />
<Property Id="WIXUI_INSTALLDIR" Value="INSTALLFOLDER" />
</Product>
<Fragment>
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="ProgramFiles64Folder">
<Directory Id="INSTALLFOLDER" Name="programName">
<Directory Id="BinDirRefId" Name="bin">
</Directory>
</Directory>
</Directory>
</Directory>
</Fragment>
<ItemGroup>
<HarvestDirectory Include="C:\example\dir">
<DirectoryRefId>BinDirRefId</DirectoryRefId>
</HarvestDirectory>
</ItemGroup>
</Wix>
Visual Studio告诉我ItemGroup
不是<Wix>
的有效子级。我应该如何正确使用该目标?
解决方法
就像vcxproj或csproj一样,它们是MsBuild的帮助者,ItemGroup也需要添加到wixproj中以简化构建。然后,您可以使用与example相同的目录ID。
根据您的尝试调整了相同的代码段:
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
...
</PropertyGroup>
<ItemGroup>
<Compile Include="foo.wxs" />
<HarvestDirectory Include="C:\example\dir">
<DirectoryRefId>BinDirRefId</DirectoryRefId>
...
</HarvestDirectory>
<WixExtension Include="WixUIExtension" />
</ItemGroup>
<Import Project="$(WixTargetsPath)" />
</Project>