大家好:我的第一篇文章!
我正在尝试使用heatdirectory使用visualstudio的“定义常量”功能获取其源目录的wixproj,其中我定义了一个常量SourceBinaries = c:\ someproject \ bin \ release。
目的是为几个项目使用相同的wixproj / setup并使用TFS-Build自动化整个...
但是,目录标签永远不会获得SourceBinaries的值。
这是xml代码:
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
blah..
<OutputName>ProjectSetup</OutputName>
blah..
</PropertyGroup>
<PropertyGroup>
<OutputPath>bin\$(Configuration)\</OutputPath>
<IntermediateOutputPath>obj\$(Configuration)\</IntermediateOutputPath>
<DefineConstants>SourceBinaries=c:\someproject\bin\release\</DefineConstants>
</PropertyGroup>
<ItemGroup>
blah..
</ItemGroup>
<Import Project="$(WixTargetsPath)" />
<Target Name="BeforeBuild">
<HeatDirectory NoLogo="$(HarvestDirectoryNoLogo)"
Directory="$(SourceBinaries)"
PreprocessorVariable="var.SourceBinaries"
SuppressAllWarnings="$(HarvestDirectorySuppressAllWarnings)"
SuppressSpecificWarnings="$(HarvestDirectorySuppressSpecificWarnings)"
ToolPath="$(WixToolPath)"
TreatWarningsAsErrors="$(HarvestDirectoryTreatWarningsAsErrors)"
TreatSpecificWarningsAsErrors="$(HarvestDirectoryTreatSpecificWarningsAsErrors)"
VerboseOutput="$(HarvestDirectoryVerboseOutput)"
AutogenerateGuids="$(HarvestDirectoryAutogenerateGuids)"
GenerateGuidsNow="$(HarvestDirectoryGenerateGuidsNow)"
OutputFile="ProductFiles.wxs"
SuppressFragments="$(HarvestDirectorySuppressFragments)"
SuppressUniqueIds="$(HarvestDirectorySuppressUniqueIds)"
Transforms="Transforms.xsl"
ComponentGroupName="ProductFiles"
DirectoryRefId="INSTALLLOCATION"
KeepEmptyDirectories="false"
SuppressCom="%(HarvestDirectory.SuppressCom)"
SuppressRootDirectory="true"
SuppressRegistry="%(HarvestDirectory.SuppressRegistry)">
</HeatDirectory>
blah..
</Target>
<Target Name="AfterBuild">
blah..
</Target>
</Project>
无论我试过什么引导我“错误”HeatDirectory“任务没有给出所需参数”目录“的值。
有人可以帮我解决这个问题吗?
提前谢谢......
迪迪埃
答案 0 :(得分:0)
您可以使用此处所述的HarvestDirectory目标http://wixtoolset.org/documentation/manual/v3/msbuild/target_reference/harvestdirectory.html。
答案 1 :(得分:0)
我认为您的主要困惑来源是 <DefineConstants>
元素中定义的变量仅适用于 .wxs 文件,但它们不适用于 .wixproj 文件本身。
要解决此问题,您可以执行以下操作:
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
blah..
<OutputName>ProjectSetup</OutputName>
blah..
</PropertyGroup>
<PropertyGroup>
<OutputPath>bin\$(Configuration)\</OutputPath>
<IntermediateOutputPath>obj\$(Configuration)\</IntermediateOutputPath>
<SourceBinaries>c:\someproject\bin\release</SourceBinaries>
<DefineConstants>SourceBinaries=$(SourceBinaries)</DefineConstants>
</PropertyGroup>
<ItemGroup>
blah..
</ItemGroup>
<Import Project="$(WixTargetsPath)" />
<Target Name="BeforeBuild">
<HeatDirectory NoLogo="$(HarvestDirectoryNoLogo)"
Directory="$(SourceBinaries)"
PreprocessorVariable="var.SourceBinaries"
SuppressAllWarnings="$(HarvestDirectorySuppressAllWarnings)"
SuppressSpecificWarnings="$(HarvestDirectorySuppressSpecificWarnings)"
ToolPath="$(WixToolPath)"
TreatWarningsAsErrors="$(HarvestDirectoryTreatWarningsAsErrors)"
TreatSpecificWarningsAsErrors="$(HarvestDirectoryTreatSpecificWarningsAsErrors)"
VerboseOutput="$(HarvestDirectoryVerboseOutput)"
AutogenerateGuids="$(HarvestDirectoryAutogenerateGuids)"
GenerateGuidsNow="$(HarvestDirectoryGenerateGuidsNow)"
OutputFile="ProductFiles.wxs"
SuppressFragments="$(HarvestDirectorySuppressFragments)"
SuppressUniqueIds="$(HarvestDirectorySuppressUniqueIds)"
Transforms="Transforms.xsl"
ComponentGroupName="ProductFiles"
DirectoryRefId="INSTALLLOCATION"
KeepEmptyDirectories="false"
SuppressCom="%(HarvestDirectory.SuppressCom)"
SuppressRootDirectory="true"
SuppressRegistry="%(HarvestDirectory.SuppressRegistry)">
</HeatDirectory>
blah..
</Target>
<Target Name="AfterBuild">
blah..
</Target>
</Project>
在上面,我们正在创建一个带有目录路径的新 <SourceBinaries>
元素。然后可以将此自定义元素用作 .wixproj 文件其余部分中的变量。然后我们使用这个值来填充 .wxs 文件中使用的 SourceBinaries
常量。
总而言之,在 <HeatDirectory>
元素中:
Directory
属性从 <SourceBinaries>
获取其值PreProcessorVariable
属性的值来自 <DefineConstants>
(或其他可用于 .wxs 文件的变量,如项目引用)