将值从TeamBuild传递到MSBuild

将值从TeamBuild传递到MSBuild,msbuild,build,build-automation,tfsbuild,Msbuild,Build,Build Automation,Tfsbuild,我有一个正在TFS TeamBuild中运行的构建。我想将一个属性从该属性传递到为TFSBuild.proj生成的每个项目运行的MSBuild 例如: TFSBuild.proj <PropertyGroup> <Version>0.0.0.0</Version> </PropertyGroup> <Target Name="BuildNumberOverrideTarget" DependsOnTargets="A

我有一个正在TFS TeamBuild中运行的构建。我想将一个属性从该属性传递到为TFSBuild.proj生成的每个项目运行的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>
<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>

0.0.0.0
$(TxCompleteVersion)
MyWIXProjectFile.wixproj

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

0.0.0.0
$(版本)
构建MyWixProjectFile.wixproj时,每次都会打印显示$(版本)为空的消息

有什么方法可以让项目文件查看TFSBuild.proj属性吗


瓦卡诺

我不是Wix方面的专家,但我确实找到了这个,我想你可以试试


这是通过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>

更改=正确
更改=正确
不更改=错误
选项1

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

选择2


将wix的out-build提取到其自身包含的脚本中,然后使用MSBuild直接调用并传递所有必要的属性。我有一个博客,上面有完整的实现,您可能对此感兴趣。

您已经验证了TFSBuild.proj中的版本是否为空正确?是的,我有。它在许多其他地方都被使用,而且一直都是正确的。遗憾的是,这对我没有帮助。我已经有一个从MSBuild到WIX的进程。从TeamBuild到MSBuild(在项目级别)的转换让我陷入了困境!谢谢你的帖子,虽然瓦卡诺