1

我正在使用 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) 解决方案,但无法将其转换为 Powershell

4

1 回答 1

3

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

[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)
于 2012-11-06T18:27:43.727 回答