【问题标题】:Pass ProcessParameters runtime (MSBuildArguments) using Powershell to tfs 2010 build definitions使用 Powershell 将 ProcessParameters 运行时 (MSBuildArguments) 传递给 tfs 2010 构建定义
【发布时间】:2017-08-12 15:49:48
【问题描述】:

我正在使用 powershell 脚本执行构建。我需要根据传递给脚本的命令行参数传递进程参数运行时间。我正在使用 TFS 2010。

[void][System.Reflection.Assembly]::LoadWithPartialName("Microsoft.TeamFoundation.Client") 
[void][System.Reflection.Assembly]::LoadWithPartialName("Microsoft.TeamFoundation.Build.Client") 

$projectName = "test"
$buildName = "test.Build"   
$tfsServer="xxx" 
$tfsInstance = [Microsoft.TeamFoundation.Client.TeamFoundationServerFactory]::GetServer($tfsServer) 
$buildService = $tfs.GetService([Microsoft.TeamFoundation.Build.Client.IBuildServer]) 
$buildDefinations = $buildService.QueryBuildDefinitions($projName) 

遍历所有构建以找到我们正在寻找的那个

foreach ($build in $buildDefinations) 
{   

获取此构建实例的名称

    $bNameInstance = $build.Name

    $ClientName = "test1" #default set in the builddefination is "/p:xxx=test"

    #Get the process parameters. I need to update the default value. How can we process the dictionary and update the value
    $bMSBuildArguments = $build.ProcessParameters

    #Once setting is done."/p:xxx=test1"
    $build.ProcessParameters = $bMSBuildArguments

    [Void]$buildService.QueueBuild($build)      

}

我在使用 powershell 代码更新流程参数方面需要帮助。我遇到了 C# (http://blogs.msdn.com/b/jpricket/archive/2010/03/25/tfs2010-queuing-a-build-from-code-with-custom-process-parameter-values.aspx)solution 但无法将其转换为 Powershell

【问题讨论】:

    标签: powershell powershell-2.0


    【解决方案1】:

    答案在提供的博客文章中。试试这样的:

    [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.TeamFoundation.Build.Workflow")
    $request = $build.CreateBuildRequest()
    $process = [Microsoft.TeamFoundation.Build.Workflow.WorkflowHelpers]::DeserializeProcessParameters($build.ProcessParameters)
    
    #make changes to your process parameters in $process
    $process.Item("asdf") = "new value"
    
    $request.ProcessParameters = [Microsoft.TeamFoundation.Build.Workflow.WorkflowHelpers]::SerializeProcessParameters($process)
    
    $buildService.QueueBuild($request)
    

    【讨论】:

      猜你喜欢
      • 2011-05-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-05-07
      • 1970-01-01
      • 1970-01-01
      • 2016-07-08
      • 2012-03-04
      相关资源
      最近更新 更多