【问题标题】:Detect the user triggering the build in VS2012 using MSBuild使用 MSBuild 检测用户在 VS2012 中触发构建
【发布时间】:2014-05-12 14:32:17
【问题描述】:

我正在使用 VS2012,我有一个目标,但我只希望它在它等于特定值时执行它。现在我想使用的值是 TFS 2010 中的“请求者”描述,它指示提出构建的用户。

但我还不知道如何检测在 MSBuild 框架中提出构建的用户。

有谁知道我该如何实现这个?我查看了 MSBuild 的 Well Known Metadata,它不包含我想要的元数据。

以下是我的目标:

<Target Name="AfterBuild" Condition="Release">
<Message Text="..RUNNING TESTS.." />
<PropertyGroup>
  <TestSuccessOrNot>1</TestSuccessOrNot>
</PropertyGroup>
<Exec Command='"C:\\Program Files (x86)\\Microsoft Visual Studio 10.0\\Common7\\IDE\\MSTest.exe" /testcontainer:C:\\Tests\\MyUnitTests.dll /test:T5278 /detail:testname '>
  <Output TaskParameter="ExitCode" PropertyName="TestSuccessOrNot" />
</Exec>
<Error Condition="$(TestSuccessOrNot) == 1" Text="Unit tests fail!" />

理想情况下,我想将该值(引发构建的用户)传递到我的目标的 Condition 属性中。

有什么想法吗?

亲切的问候,

【问题讨论】:

    标签: c# visual-studio-2012 tfs msbuild


    【解决方案1】:

    属性是RequestedByRequestedFor,但不确定它们何时不同。条件应该类似于 Condition=" '$(RequestedBy)' == 'anyUserName'" 对于用户,这将是显示名称,而对于触发的构建,它将是 [CollectionName]\Project Collection Service Accounts

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-08-18
      • 1970-01-01
      • 2015-05-13
      • 2020-03-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多