gpt4 book ai didi

powershell - 找不到类型 [Microsoft.TeamFoundation.Build.Workflow.WorkflowHelpers]

转载 作者:行者123 更新时间:2023-12-02 03:47:39 24 4
gpt4 key购买 nike

我正在尝试从指定过程参数的 Powershell 中对构建进行排队。我收到以下错误...知道我做错了什么吗?

无法找到类型 [Microsoft.TeamFoundation.Build.Workflow.WorkflowHelpers]:确保已加载包含此类型的程序集。

第 19 行字符:1
+ $paramValues = [Microsoft.TeamFoundation.Build.Workflow.WorkflowHelpers]::Deseri ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~+ CategoryInfo : InvalidOperation: (Microsoft.TeamF...WorkflowHelpers:TypeName) [], 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")

最佳答案

不在 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'

关于powershell - 找不到类型 [Microsoft.TeamFoundation.Build.Workflow.WorkflowHelpers],我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15949903/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com