2013-04-11 125 views
3

我想排隊從Powershell指定過程參數的構建。我收到以下錯誤...任何想法我做錯了什麼?無法找到類型[Microsoft.TeamFoundation.Build.Workflow.WorkflowHelpers]

無法找到類型[Microsoft.TeamFoundation.Build.Workflow.WorkflowHelpers]:確保包含此類型的程序集已加載。

At line:19 char:1
+ $ paramValues = [Microsoft.TeamFoundation.Build.Workflow.WorkflowHelpers] :: Deseri ...
+ ~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~ + CategoryInfo:InvalidOperation:(Microsoft.TeamF ... WorkflowHelpers:類型名)[],的RuntimeException
+ FullyQualifiedErrorId:TypeNotFound`

function Get-BuildServer 
     { 
     param($serverName = $(throw 'please specify a TFS server name')) 
     [void][System.Reflection.Assembly]::LoadWithPartialName("Microsoft.TeamFoundation.Client") 
     [void][System.Reflection.Assembly]::LoadWithPartialName("Microsoft.TeamFoundation.Build.Client") 
     $tfs = [Microsoft.TeamFoundation.Client.TeamFoundationServerFactory]::GetServer($serverName) 

     return $tfs.GetService([Microsoft.TeamFoundation.Build.Client.IBuildServer]) 
     } 

    # SAS: Get the Build Server 
    $buildserver = Get-BuildServer "http://tfsserver:8080/tfs/My%20Project%20Collection" 

    # SAS: Set the parameters (Team Project and Build Definition) 
    $teamProject = "MyProject" 
    $buildDefinition = "MyBuildDefinition" 

    # SAS: Get the build definition 
    $definition = $buildserver.GetBuildDefinition($teamProject, $buildDefinition) 

    # SAS: Create the build request 
    $request = $definition.CreateBuildRequest() 

    # SAS: Deserialise the Process Parameter for the Build Definition 
    [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.TeamFoundation.Build.Workflow") 
    $paramValues = [Microsoft.TeamFoundation.Build.Workflow.WorkflowHelpers]::DeserializeProcessParameters($request.ProcessParameters) 

    # SAS: Set the parameter(s) 
    $paramValues.Item("asdf") = "new value" 

    # SAS: Serialise the Process Parameter for the Build Definition 
    $request.ProcessParameters = [Microsoft.TeamFoundation.Build.Workflow.WorkflowHelpers]::SerializeProcessParameters($paramValues) 

    # SAS: Queue the build 
    $buildserver.QueueBuild($request, "None") 
+0

簡單......不是在GAC!哎呀!不管怎麼說......但是它已經解決了:-) – SuperSooty 2013-04-11 13:55:30

+0

在VS2015和TFS電動工具上使用Powershell的新Windows 10機器我驚訝地發現這些DLL不再位於Program Files(x86)\ Visual studio版本下,但是而是必須從「C:\ Program Files文件(x86)\ Microsoft團隊基礎服務器2015年電源工具」中引用,它爲我解決了相同的錯誤。 – rob 2016-01-20 09:09:53

回答

1

不在GAC !您需要DLL到GAC 或 試試這個

add-type -Path 'C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\ReferenceAssemblies\v2.0\Microsoft.TeamFoundation.Build.Workflow.dll'