2

大家好:我的第一篇文章!

我正在尝试使用 heatdirectory 获取 wixproj,以使用 visualstudio 的“定义常量”功能获取其源目录,其中我定义了一个常量 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”任务没有为所需参数“Directory”提供值。
有人可以帮我解决这个问题吗?提前谢谢...

迪迪埃

4

2 回答 2

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 文件其余部分中的变量。然后我们使用这个值来填充SourceBinaries.wxs 文件中使用的常量。

总之,在<HeatDirectory>元素中:

  • Directory属性的值来自<SourceBinaries>
  • PreProcessorVariable属性的值来自<DefineConstants>(或其他可用于 .wxs 文件的变量,如项目引用)
于 2021-07-23T15:41:49.787 回答
-1

您可以使用此处描述的 HarvestDirectory 目标http://wixtoolset.org/documentation/manual/v3/msbuild/target_reference/harvestdirectory.html

于 2014-03-06T10:47:19.207 回答