views:

551

answers:

3

I have a build that is running in TFS TeamBuild. I want to pass a property from that to the MSBuild that is run for each Project built by the TFSBuild.proj.

Example:

TFSBuild.proj

<PropertyGroup>
   <Version>0.0.0.0</Version>
</PropertyGroup>

<Target Name="BuildNumberOverrideTarget" 
        DependsOnTargets="AfterInitializeWorkspace">

  <!--Code that loads the version from a file (removed).-->

  <PropertyGroup>
    <!--Save off the version.-->
    <Version>$(TxCompleteVersion)</Version>
</PropertyGroup>

MyWIXProjectFile.wixproj

<Target Name="BeforeBuild">
<PropertyGroup>
  <!--If Version is defined then use that.  
   Else just use all zeros to show that this is a developer built version-->
  <CurrentVersion Condition="'$(Version)' == ''" >0.0.0.0</CurrentVersion>
  <CurrentVersion Condition="'$(Version)' != ''" >$(Version)</CurrentVersion>
</PropertyGroup>
<Message Condition="'$(Version)' == ''" 
         Text="Version info is empty (i.e. a developer build).  Version set to $(CurrentVersion)"/>

</Target>

When the MyWixProjectFile.wixproj gets built the message showing that the $(Version) is blank gets printed every time.

Is there someway that I can get the project file to see the TFSBuild.proj properties?

Vaccano

A: 

Im not an expert in Wix but I did find this and thought you could give it a try.

Setting properties for WiX in MSBuild

Robert Kozak
Sadly this does not help me. I already have a process to go from MSBuild to WIX. It is getting from TeamBuild to MSBuild (at the project level) that has me stuck!Thanks for the post thoughVaccano
Vaccano
A: 

This is done via the properties metadata in the SolutionToBuild tag. For example:

  <ItemGroup>
    <SolutionToBuild Include="$(BuildProjectFolderPath)\ChangeThisOne.sln">
      <Targets></Targets>
      <Properties>Change=True</Properties>
    </SolutionToBuild>
    <SolutionToBuild Include="$(BuildProjectFolderPath)\ChangeThisToo.sln">
      <Targets></Targets>
      <Properties>Change=True</Properties>
    </SolutionToBuild>
    <SolutionToBuild Include="$(BuildProjectFolderPath)\DontChangeThis.sln">
      <Targets></Targets>
      <Properties>Don'tChange=False</Properties>
    </SolutionToBuild>
  </ItemGroup>
Vaccano
A: 

Option 1

Use MSBuild to directly call MyWIXProjectFile.wixproj and pass Version as property

Option 2

Abstract out build of wix out to its own selft contained script and then use MSBuild to call directly and passing all necessary properties. I have blog with full implementation doing this at http://blog.newagesolution.net/2008/06/how-to-use-msbuild-and-wix-to-msi.html that might be of interest to you.

NewAgeSolution