将值从TeamBuild传递到MSBuild

时间:2009-05-08 20:33:31

标签: msbuild build build-automation tfsbuild team-build

我有一个在TFS TeamBuild中运行的构建。我想将一个属性从那个传递给为TFSBuild.proj构建的每个Project运行的MSBuild。

示例:

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>

当构建MyWixProjectFile.wixproj时,每次都会打印显示$(Version)为空的消息。

有没有我可以获取项目文件来查看TFSBuild.proj属性?

Vaccano

3 个答案:

答案 0 :(得分:0)

我不是Wix的专家,但我确实找到了这个,并认为你可以尝试一下。

Setting properties for WiX in MSBuild

答案 1 :(得分:0)

这是通过SolutionToBuild标记中的属性元数据完成的。例如:

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

答案 2 :(得分:0)

选项1

使用MSBuild直接调用MyWIXProjectFile.wixproj并将Version作为属性传递

选项2

将wix的构建抽象出自己的selft包含的脚本,然后使用MSBuild直接调用并传递所有必需的属性。我有一个博客,可以在http://blog.newagesolution.net/2008/06/how-to-use-msbuild-and-wix-to-msi.html处完全实现,这可能是您感兴趣的。