我正在尝试创建一个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()
我得到的错误无法保存,因为未定义过程。我在这里错过了什么?