【问题标题】:MSBuild build fails when trying to use the "Get" task尝试使用“获取”任务时 MSBuild 构建失败
【发布时间】:2013-03-24 01:16:42
【问题描述】:

我正在进行从 TFS2010 到 TFS2012 的测试升级。他们正在使用升级模板来运行大量自定义 MSBuild 任务,以自动化他们的构建和部署。 MSBuild 项目最初是为 TFS2005 创建的,并在某些时候直接升级到 TFS2010。他们正在构建的解决方案主要针对 .NET 2.0,并且他们仍在使用 VS2005 进行大部分开发。

到目前为止,我已经安装了带有 Update 1 的 VS2005、VS2010 和 TFS2012(按此顺序),并将它们的 TFS2010 数据库升级到 TFS2012。构建控制器与应用层和数据库位于同一台机器上,只是因为这是一个“概念验证”升级,以识别在真正升级之前需要在构建过程中解决的任何问题。

当我运行他们的任何基于 MSBuild 的构建时,我收到以下错误:

C:\Builds\18\Web\ES-INTEGRATION-WebTest\BuildType\TFSBuild.proj (75): 类型的扩展 'Microsoft.TeamFoundation.Build.Client.IBuildDetail' 必须是 配置以运行此工作流程。 C:\Builds\18\Web\ES-INTEGRATION-WebTest\BuildType\TFSBuild.proj (75): “获取”任务意外失败。

System.Activities.ValidationException:类型的扩展 'Microsoft.TeamFoundation.Build.Client.IBuildDetail' 必须是 配置以运行此工作流。

在 System.Activities.Hosting.WorkflowInstanceExtensionCollection..ctor(活动 workflowDefinition, WorkflowInstanceExtensionManager extensionManager)

在 System.Activity.Hosting.WorkflowInstanceExtensionManager.CreateInstanceExtensions(活动 workflowDefinition, WorkflowInstanceExtensionManager extensionManager)

在 System.Activity.Hosting.WorkflowInstance.RegisterExtensionManager(WorkflowInstanceExtensionManager 扩展管理器)

在 System.Activities.WorkflowApplication.EnsureInitialized()

在 System.Activity.WorkflowApplication.RunInstance(WorkflowApplication 实例)

在 System.Activities.WorkflowApplication.Invoke(活动活动, IDictionary`2 输入,WorkflowInstanceExtensionManager 扩展, TimeSpan 超时)

在 System.Activities.WorkflowInvoker.Invoke(活动工作流, IDictionary`2 输入,TimeSpan 超时, WorkflowInstanceExtensionManager 扩展)

在 Microsoft.TeamFoundation.Build.Tasks.WorkflowTask.ExecuteInternal()

在 Microsoft.TeamFoundation.Build.Tasks.Task.Execute()

在 Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()

在 Microsoft.Build.BackEnd.TaskBuilder.d__20.MoveNext()

我已经完成并将构建缩减为一个重现问题的非常小的案例。完整的.proj文件如下:

<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="DesktopBuild" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">

    <!-- Do not edit this -->
    <Import Project="$(MSBuildExtensionsPath)\Microsoft\VisualStudio\TeamBuild\Microsoft.TeamFoundation.Build.targets" />
    <ProjectExtensions>
        <!--  DESCRIPTION
     The description is associated with a build type. Edit the value for making changes.
    -->
        <Description>Builds and Deploys the BE site to the integration environment</Description>
        <!--  BUILD MACHINE
     Name of the machine which will be used to build the solutions selected.
    -->
        <BuildMachine>[redacted]</BuildMachine>
    </ProjectExtensions>
    <PropertyGroup>
        <!--  TEAM PROJECT
     The team project which will be built using this build type.
    -->
        <TeamProject>Web</TeamProject>
        <!--  BUILD DIRECTORY
     The directory on the build machine that will be used to build the
     selected solutions. The directory must be a local path on the build
     machine (e.g. c:\build).
    -->
        <BuildDirectoryPath>c:\build</BuildDirectoryPath>
        <!--  DROP LOCATION
      The location to drop (copy) the built binaries and the log files after
     the build is complete. This location has to be a valid UNC path of the
     form \\Server\Share. The build machine service account and application
     tier account need to have read write permission on this share.
    -->
        <DropLocation>\\[redacted]\BuildDrop</DropLocation>
        <!--  TESTING
     Set this flag to enable/disable running tests as a post build step.
    -->
        <RunTest>True</RunTest>
        <!--  WorkItemFieldValues
      Add/edit key value pairs to set values for fields in the work item created
      during the build process. Please make sure the field names are valid 
      for the work item type being used.
    -->
        <WorkItemFieldValues>Symptom=build break;Steps To Reproduce=Start the build using Team Build</WorkItemFieldValues>
        <!--  CODE ANALYSIS
       To change CodeAnalysis behavior edit this value. Valid values for this
       can be Default,Always or Never.

     Default - To perform code analysis as per the individual project settings
     Always  - To always perform code analysis irrespective of project settings
     Never   - To never perform code analysis irrespective of project settings
     -->
        <RunCodeAnalysis>Default</RunCodeAnalysis>
        <!--  UPDATE ASSOCIATED WORK ITEMS
     Set this flag to enable/disable updating associated workitems on a successful build
    -->
        <UpdateAssociatedWorkItems>false</UpdateAssociatedWorkItems>
        <!-- Title for the work item created on build failure -->
        <WorkItemTitle>Build failure in build:</WorkItemTitle>
        <!-- Description for the work item created on build failure -->
        <DescriptionText>This work item was created by Team Build on a build failure.</DescriptionText>
        <!-- Text pointing to log file location on build failure -->
        <BuildlogText>The build log file is at:</BuildlogText>
        <!-- Text pointing to error/warnings file location on build failure -->
        <ErrorWarningLogText>The errors/warnings log file is at:</ErrorWarningLogText>
    </PropertyGroup>



    <PropertyGroup>
        <SourceBranchPath>Main</SourceBranchPath>
    </PropertyGroup>

  <!-- Does some basic validation of the environment before the build starts -->
  <Target Name="PreBuildValidations" >
    <Get FileSpec="$/Web/$(SourceBranchPath)/BuildFiles/Tools/PSExec.exe" Workspace="$(WorkspaceName)" Recursive="false" Force="true" TeamFoundationServerUrl="$(TeamFoundationServerUrl)"/>
  </Target>

    <Target Name="BeforeGet">
        <CallTarget Targets="PreBuildValidations" />
    </Target>


</Project>

【问题讨论】:

  • tfsbuild.proj 中ProjectFileVersion 的值是多少?
  • ProjectFileVersion 是 4。
  • MSBuild 平台设置为x86
  • 您的工作区是否包含文件规范?

标签: tfs msbuild build-automation


【解决方案1】:

我想通了。显然,Get 任务需要 BuildUri 参数。我添加了BuildUri="$(BuildURI)",一切都很好。

【讨论】:

    【解决方案2】:

    您的构建在您的 msbuild 脚本中的“Get Task”上失败。您只在 BeforeGet 目标中拉下一个 .exe 文件。为了构建项目,您需要一个项目文件。

    看起来错误可能是因为您在 Get 任务中缺少参数或传入了无效参数。

    当构建可以从构建定义工作区拉出文件时,为什么需要预构建验证步骤?

    【讨论】:

    • 是的,我知道 哪里 失败了。我已经确认传递给Get 任务的参数是有效的。请记住,这完全适用于 TFS2010 环境。至于“它为什么做它做的事”,这是很久以前别人创造的。我不知道他们为什么做出他们所做的决定。在 TFS2012 升级之后,目的是将整个构建过程升级到更现代的东西。
    • 如果您从本地机器上的命令行运行 msbuild,您会收到错误消息吗?这将确保 Get 任务具有正确的参数。
    • 当解决方案是无效参数时,为什么要投反对票?我在答案中将此表示为可能的问题。我还参考了 GetTask MSDN 页面,其中显示了所需的参数和示例。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2019-06-07
    • 1970-01-01
    • 1970-01-01
    • 2018-05-30
    • 1970-01-01
    • 2013-10-23
    • 1970-01-01
    相关资源
    最近更新 更多