3

hello everybody : my first post !

i am trying to get a wixproj using heatdirectory to take its source directory using visualstudio's "Define Constants" feature, in which i define a constant SourceBinaries=c:\someproject\bin\release.

The purpose is to use the same wixproj/setup for several projects and automate the whole with TFS-Build...

however, the Directory Tag never gets the SourceBinaries's value.

here's the xml code :

<?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>

whatever i tried lead me to "Error The "HeatDirectory" task was not given a value for the required parameter "Directory".
can somebody help me resolving this ? thanks in advance...

Didier

2 Answers2

3

I think your main source of confusion is that the variables defined in the <DefineConstants> element only work for the .wxs files, but they will not work in the .wixproj file itself.

To fix this you could do something like:

<?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>

Above, we're creating a new <SourceBinaries> element with the path to the directory. This custom element can then be used as a variable in the rest of the .wixproj file. We then use this value to populate the SourceBinaries constant that is used in the .wxs files.

In conclusion, in the <HeatDirectory> element:

  • the Directory attribute gets its value from <SourceBinaries>
  • The PreProcessorVariable attribute gets its value from <DefineConstants> (or other variables available to .wxs files like project references)
Jen Garcia
  • 699
  • 5
  • 18
-1

You could use the HarvestDirectory target as described here http://wixtoolset.org/documentation/manual/v3/msbuild/target_reference/harvestdirectory.html.

IliaJ
  • 159
  • 3