我是WiX的新手.很新.有没有办法同时定义ComponentGroup和Directory?
我有大量的文件,大约300个左右,需要分成多个组,每组有大约50个文件.
使用heat.exe,我能够创建一个Fragment,为每个文件创建组件.我想避免在单独的ComponentGroup定义中重新列出这些组件中的每一个.我希望能够在ComponentGroup定义中包装由heat生成的组件列表,然后只需在DirectoryRef结构中使用该ComponentGroupRef.
我希望这能搞清楚.我目前必须这样做:
<DirectoryRef Id="FilesDir">
<Component Id="a.txt" Guid="YOUR-GUID">
<File Id="a.txt" KeyPath="yes" Source="SourceDir\a.txt" />
</Component>
<Component Id="b.txt" Guid="YOUR-GUID">
<File Id="b.txt" KeyPath="yes" Source="SourceDir\b.txt" />
</Component>
...
<Component Id="z.txt" Guid="YOUR-GUID">
<File Id="z.txt" KeyPath="yes" Source="SourceDir\z.txt" />
</Component>
</DirectoryRef>
<ComponentGroup Id="FilesGroup">
<ComponentRef Id="a.txt">
<ComponentRef Id="b.txt">
...
<ComponentRef Id="z.txt">
</ComponentGroup>
Run Code Online (Sandbox Code Playgroud)
我必须两次列出每个文件.臭死了.
我希望能够做到:
<ComponentGroup Id="FilesGroup">
<Component Id="a.txt" Guid="YOUR-GUID">
<File Id="a.txt" KeyPath="yes" Source="SourceDir\a.txt" />
</Component>
<Component Id="b.txt" Guid="YOUR-GUID">
<File Id="b.txt" KeyPath="yes" Source="SourceDir\b.txt" />
</Component>
...
<Component Id="z.txt" Guid="YOUR-GUID">
<File Id="z.txt" KeyPath="yes" Source="SourceDir\z.txt" />
</Component>
</ComponentGroup>
<DirectoryRef Id="FilesDir">
<ComponentGroupRef Id="FilesGroup">
</DirectoryRef>
Run Code Online (Sandbox Code Playgroud)
那可能吗?有没有其他方法让我更容易,我只是没有看到?
更新:我们放弃了Wix,因此我不确定是否应该标记解决方案.如果有人觉得下面的答案之一是我现在相当老的问题的答案,请告诉我,我会在这样的情况下标出相应的答案.
我希望我理解你的问题是正确的.我在每个构建上使用加热工具来自动生成包含目标构建输出目录内容的组件的wxs.WXS(简化后)如下所示:
<?xml version="1.0" encoding="utf-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Fragment>
<ComponentGroup Id="CompGroup01">
<Component Id="cmp1D6110E9A0B9E351095F414BEB4D2E35" Directory="Dir01" Guid="*">
<File Id="fil53541B947C7CE0A96A604898F1B825C5" KeyPath="yes" Source="$(var.HarvestDir)\somefile.exe" />
</Component>
</ComponentGroup>
</Fragment>
</Wix>
Run Code Online (Sandbox Code Playgroud)
在Product.wxs中我有这个硬编码链接到自动生成的代码:
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="ProgramFilesFolder" Name="PFiles">
<Directory Id="INSTALLDIR" Name="myInstallDir">
<Directory Id="Dir01" Name="myInstallSubDir" />
</Directory>
</Directory>
</Directory>
<Feature Id="ProductFeature" Title="MyProductComplete" Level="1">
<ComponentGroupRef Id="CompGroup01" />
</Feature>
Run Code Online (Sandbox Code Playgroud)
在wixproj文件中定义了一个"收获任务"(它不是绝对干净,但它有效).wixproj不完整,我删除了所有不相关的部分:
<PropertyGroup>
<!-- relative path to directory from which setup will load input files -->
<MyWixSourceDir>C:\bin</MyWixSourceDir>
<!-- relative path to directory where inputs will be temporarily copied during harvesting -->
<MyWixHarvestDir>tempHarvest</MyWixHarvestDir>
<DefineConstants>Debug;HarvestDirApp=$(ProjectDir)$(MyWixHarvestDir)</DefineConstants>
</PropertyGroup>
<ItemGroup>
<!-- defines item group containing files which represent automatically harvested input for our WiX setup -->
<SetupInputFiles Include="$(MyWixSourceDir)\**\*.*" />
</ItemGroup>
<ItemGroup>
<!-- defines item group of autogenerated files -->
<AutoGeneratedFiles Include="*.autogenerated.wxs" />
</ItemGroup>
<Target Name="BeforeBuild">
<!-- 1) prepare harvesting -->
<!-- remove temporary harvesting directory in case previous build did not cleaned up its temp files and folders -->
<RemoveDir Directories="$(ProjectDir)$(MyWixHarvestDir)" />
<!-- delete old autogenerated files first -->
<Delete Files="@(AutoGeneratedFiles)" ContinueOnError="false" />
<!-- 2) harvest application build output -->
<!-- copies input files into temporary directory so that they can be harvested into WXS file -->
<Copy SourceFiles="@(SetupInputFiles)" DestinationFiles="@(SetupInputFiles->'$(ProjectDir)$(MyWixHarvestDir)\%(RecursiveDir)%(Filename)%(Extension)')" ContinueOnError="false" />
<!-- harvest files and produce WXS file defining all file and directory components for the setup -->
<Exec Command=""$(WixExtDir)heat" dir $(ProjectDir)$(MyWixHarvestDir) -dr Dir01 -sreg -srd -ag -cg CompGroup01 -var var.HarvestDirApp -out InstallDirApp.autogenerated.wxs" ContinueOnError="false" WorkingDirectory="." />
</Target>
<Target Name="AfterBuild">
<!-- 4) clean-up: remove temporary harvesting directory -->
<RemoveDir Directories="$(ProjectDir)$(KbcWixHarvestDir)" />
</Target>
Run Code Online (Sandbox Code Playgroud)
最重要的是执行收获的Exec元素.我使用"-dr Dir01"来定义组件将"Dir01"作为父目录引用,并使用"-cg ComGroup01"来定义componentGroup.
归档时间: |
|
查看次数: |
13681 次 |
最近记录: |