AssemblyInfo.cs文件的自动更新和签入有时会导致部分失败

时间:2008-10-06 15:14:54

标签: tfs msbuild assemblies

我们有TFS 2008我们的构建设置来检查项目中的所有AssemblyInfo.cs文件,使用AssemblyInfoTask更新它们,然后根据是否通过构建撤消checkout或checkin。不幸的是,当两个构建排列在一起时,这会导致部分完成构建,因为AssemblyInfo.cs文件似乎在早期版本中签出到上一个签入。

为了解决这个问题,我认为我可以使用“Get”任务在更新它们之前将AssemblyInfo.cs文件强制为最新版本,但这似乎没有任何效果。有什么想法吗?

<Target Name="AfterGet" Condition="'$(IsDesktopBuild)'!='true'">
<Message Text="SolutionRoot = $(SolutionRoot)" />
<Message Text="OutDir = $(OutDir)" />
<!-- Set the AssemblyInfoFiles items dynamically -->
<CreateItem Include="$(SolutionRoot)\Main\Source\InputApplicationSln\**\$(AssemblyInfoSpec)">
  <Output ItemName="AssemblyInfoFiles" TaskParameter="Include" />
</CreateItem>

<Message Text="$(AssemblyInfoFiles)" />

<!-- When builds are queued up successively, it is possible for the next build to be set up before the AssemblyInfoSpec is checked in so we need to force 
    the latest these versions of these files to be got before a checkout -->
<Get Condition=" '$(SkipGet)'!='true' " TeamFoundationServerUrl="$(TeamFoundationServerUrl)" Workspace="$(WorkspaceName)" Filespec="$(AssemblyInfoSpec)"  Recursive="$(RecursiveGet)" Force="$(ForceGet)" />

<Exec WorkingDirectory="$(SolutionRoot)\Main\Source\InputApplicationSln"
          Command="$(TF) checkout /recursive $(AssemblyInfoSpec)"/>

    

2 个答案:

答案 0 :(得分:0)

您的构建是否重新编写AssemblyInfo文件,然后重新检入它们?或者您只是在本地修改AssemblyInfo文件。我个人更喜欢后一种方法 - 正如在TFSBuild收件人网站上所记录的那样:

http://tfsbuild.com/AssemblyVersioning%20.ashx

我从来没有真正坐下来检查,但我想知道你是否检查了AssemblyInfo文件,然后可能会发生以下情况,这可能会导致你的问题......

  1. 请求构建,当前更改集= 42
  2. 变更集42的构建1开始运行
  3. 请求构建,当前变更集= 42(仍然)
  4. 构建2 for changeset 42排队
  5. 构建1检查新的assemblyinfo文件,当前changeset = 43
  6. 构建1完成
  7. 更改集42的构建2启动,显示变更集42,这意味着AssemblyInfo文件是折叠的。
  8. 正如我所说,不确定何时确定构建的变更集编号 - 在排队时或在运行时。但是在排队时它更有意义。

答案 1 :(得分:0)

更改:

<Get Condition=" '$(SkipGet)'!='true' " TeamFoundationServerUrl="$(TeamFoundationServerUrl)" Workspace="$(WorkspaceName)" Filespec="$(AssemblyInfoSpec)"  Recursive="$(RecursiveGet)" Force="$(ForceGet)" />

要:

<Get Condition=" '$(SkipGet)'!='true' " TeamFoundationServerUrl="$(TeamFoundationServerUrl)" Workspace="$(WorkspaceName)" Filespec="$(AssemblyInfoSpec)"  Recursive="True" Force="True" />

强制使用树顶覆盖AssemblyInfo.cs文件。到目前为止它一直在工作,但更多的是黑客而不是优雅。