gpt4 book ai didi

tfs - Microsoft.TeamFoundation.VersionControl.Client.ItemNotMappedException 即使工作区存在并且具有映射

转载 作者:行者123 更新时间:2023-12-05 01:17:17 25 4
gpt4 key购买 nike

使用 TFS 2015 update 2,在一台机器上安装了一个代理,代理创建了它的工作空间:

enter image description here

内部开发的一些自定义 MSBuild 任务已在将在代理上运行的构建定义中实现。这些任务对 TFS 服务器执行一些操作。

当构建定义排队等待新构建时,我得到的是:

enter image description here

在构建机器中,我继续运行以下脚本,以验证工作区是否存在:

# Script to find a Team Foundation workspace
param(
[string] $workspaceHint = $(get-location).Path
)

begin
{
# load the needed client dll's
[void][System.Reflection.Assembly]::LoadWithPartialName("Microsoft.TeamFoundation.Client")
[void][System.Reflection.Assembly]::LoadWithPartialName("Microsoft.TeamFoundation.VersionControl.Client")

# fetches a Workspace instance matching the WorkspaceInfo found in the cache file
function getWorkspaceFromWorkspaceInfo($wsInfo)
{
$tfs = [Microsoft.TeamFoundation.Client.TeamFoundationServerFactory]::GetServer($wsInfo.ServerUri.AbsoluteUri)
$vcs = $tfs.GetService([Microsoft.TeamFoundation.VersionControl.Client.VersionControlServer])
$vcs.GetWorkspace($wsInfo)
# TODO: likely add some convenience properties/methods for easier scripting support
}
}

process
{
# is there only 1 workspace in our cache file? If so, use that one regardless of the hint
$workspaceInfos = [Microsoft.TeamFoundation.VersionControl.Client.Workstation]::Current.GetAllLocalWorkspaceInfo()
if ($workspaceInfos.Length -eq 1)
{
return getWorkspaceFromWorkspaceInfo($workspaceInfos[0])
}

if (test-path $workspaceHint)
{
# workspace hint is a local path, get potential matches based on path
$workspaceInfos = [Microsoft.TeamFoundation.VersionControl.Client.Workstation]::Current.GetLocalWorkspaceInfoRecursively($workspaceHint)
}
else
{
# workspace hint is NOT a local path, get potential matches based on name
$workspaceInfos = @($workspaceInfos | ?{ $_.name -match $workspaceHint })
}

if ($workspaceInfos.Length -gt 1)
{
throw 'More than one workspace matches the workspace hint "{0}": {1}' -f
$workspaceHint, [string]::join(', ', @($workspaceInfos | %{ $_.Name}))
}
elseif ($workspaceInfos.Length -eq 1)
{
return getWorkspaceFromWorkspaceInfo($workspaceInfos[0])
}
else
{
throw "Could not figure out a workspace based on hint $workspaceHint"
}
}

脚本无法找到任何工作区。

然后,TFS 2015 Power 工具及其 powershell cmdlet 安装在机器中并运行以下脚本:

if ( (Get-PSSnapin -Name Microsoft.TeamFoundation.PowerShell -ErrorAction SilentlyContinue) -eq $null )
{
Add-PSSnapin -Name Microsoft.TeamFoundation.PowerShell
}
$ws = Get-TfsWorkspace -Path C:\t\1\s

$ws.Folders

显示工作区和映射的项目。

排队新构建,继续显示相同的错误。工作区是一个公共(public)服务器,按照 msdn 论坛中的一些古老帖子,我清理了机器中的 TFS 缓存。

知道如何让 Microsoft.TeamFoundation.VersionControl.Client 能够识别工作区吗?

最佳答案

我通过运行类似于以下 PowerShell 脚本的程序修复了我机器上的 ItemNotMappedException 问题;

$localReference = "C:\Repository\Project\Project.sln"
$teamProjectCollection="http://tfsserver:8080/tfs/projectcollection"
$username = $env:UserName


Add-type -AssemblyName "Microsoft.TeamFoundation.Client, Version=12.0.0.0, Culture=Neutral, PublicKeyToken=b03f5f7f11d50a3a"
Add-type -AssemblyName "Microsoft.TeamFoundation.Common, Version=12.0.0.0, Culture=Neutral, PublicKeyToken=b03f5f7f11d50a3a"
Add-type -AssemblyName "Microsoft.TeamFoundation.VersionControl.Client, Version=12.0.0.0, Culture=Neutral, PublicKeyToken=b03f5f7f11d50a3a"
Add-type -AssemblyName "Microsoft.TeamFoundation.VersionControl.Common, Version=12.0.0.0, Culture=Neutral, PublicKeyToken=b03f5f7f11d50a3a"

$folder = [System.IO.Path]::GetDirectoryName($localReference);
Push-Location $folder;

$tfsTeamProjectCollection = New-Object Microsoft.TeamFoundation.Client.TfsTeamProjectCollection($teamProjectCollection)
$versioncontrolServer = $tfsTeamProjectCollection.GetService([Microsoft.TeamFoundation.VersionControl.Client.VersionControlServer])
[Microsoft.TeamFoundation.VersionControl.Client.Workstation]::Current.EnsureUpdateWorkspaceInfoCache($versionControlServer, $username);
$workspace = $versioncontrolServer.GetWorkspace($localReference)
echo $workspace

Pop-Location

您需要更改初始变量以匹配您的环境。

希望对你有帮助

关于tfs - Microsoft.TeamFoundation.VersionControl.Client.ItemNotMappedException 即使工作区存在并且具有映射,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41902276/

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