将值从TeamBuild传递到MSBuild

时间:2021-03-10 13:58:44

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.

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

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.

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

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

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

Vaccano

3 个解决方案

#1


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

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

Setting properties for WiX in MSBuild

在MSBuild中设置WiX的属性

#2


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

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

#3


Option 1

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

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

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.

摘要构建wix到其自己的selft包含的脚本,然后使用MSBuild直接调用并传递所有必需的属性。我在http://blog.newagesolution.net/2008/06/how-to-use-msbuild-and-wix-to-msi.html上有完整实施的博客,您可能对此感兴趣。

#1


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

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

Setting properties for WiX in MSBuild

在MSBuild中设置WiX的属性

#2


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

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

#3


Option 1

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

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

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.

摘要构建wix到其自己的selft包含的脚本,然后使用MSBuild直接调用并传递所有必需的属性。我在http://blog.newagesolution.net/2008/06/how-to-use-msbuild-and-wix-to-msi.html上有完整实施的博客,您可能对此感兴趣。