1

我正在尝试创建一个 powershell 脚本来创建 TFS 构建定义。我在 C# 中创建这个示例(http://geekswithblogs.net/jakob/archive/2010/04/26/creating-a-build-definition-using-the-tfs-2010-api.aspx)。但是,我在创建构建定义时遇到了麻烦。

我的脚本:

param(
[Parameter(Mandatory=$true)]
[string] $buildName,`enter code here`
[string] $teamProject="Templates",
[string] $buildTemplateName = "TestBuildTemplate",
[string] $buildDescription = "Test Descirption",
[string] $buildController = "TFS - Controller"
)

Clear-Host

$ErrorActionPreference = “Stop” ;
if ($Verbose) { $VerbosePreference = “Continue” ; }

$assemblylist = 
"Microsoft.TeamFoundation.Build.Client",
"Microsoft.TeamFoundation.Build.Workflow",
"Microsoft.TeamFoundation.Client",
"Microsoft.TeamFoundation.Common",
"Microsoft.TeamFoundation.WorkItemTracking.Client"

Write-Verbose -Message “Loading TFS Build assembly…”

foreach ($asm in $assemblylist)
{
    $asm = [Reflection.Assembly]::LoadWithPartialName($asm)
}

 $tfsCollectionUrl = "TFS Server IP Address"

 $server.EnsureAuthenticated()
 if(!$server.HasAuthenticated)
 {
    Write-Host "Failed to authenticate TFS"
    exit
 }

 Write-Host "Connected to TFS...."

 $buildServer = $server.GetService([Microsoft.TeamFoundation.Build.Client.IBuildServer])

 $def = $buildserver.CreateBuildDefinition($teamProject)
 $def.Name = $buildTemplateName
 $def.Description = $buildDescription


 $def.Workspace.AddMapping("$/Default/Sampleapplication1", '"$(SourceDir)"', 0)
 $def.Workspace.AddMapping('"$/OtherPath/"', "", 1)

 $def.BuildController = $buildserver.GetBuildController($buildController)
 $def.DefaultDropLocation = "Drop Location Share"


 $def.Save()

我得到的错误无法保存,因为未定义进程。我在这里想念什么?

4

0 回答 0