我嘗試通過PowerShell腳本在VisualStudio中打開成功構建的詳細頁面。我能夠連接到我的測試項目和某個BuildDefinition的集合。我爲每個構建都獲得了vstfs-Link,但是如何在Visual Studio中打開此鏈接? 我試着用EncodeUri,GetArtifactUrl和GetArtifactUrlExternal。對於GetArtifactUrl我得到這個錯誤:在Visual Studio中通過PowerShell腳本打開VSTFS鏈接
無法轉換爲「GetArtifactUrl」鍵入「Microsoft.TeamFoundation.ArtifactId」參數值「artId」,值爲:「vstfs:/// Build/Build/12345」:「Can not將類型「System.Uri」的「vstfs:/// Build/Build/12345」值轉換爲鍵入 「Microsoft.TeamFoundation.ArtifactId」。「
任何人都可以給我一些建議如何將vstfs鏈接轉換爲我可以在VisualStudio中打開的東西?
感謝
[void] [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.TeamFoundation.Client")
[void] [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.TeamFoundation.Build.Client")
[void] [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.TeamFoundation.VersionControl.Client")
[void] [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.TeamFoundation.Common")
[void] [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.VisualStudio.TeamFoundation")
[void] [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.VisualStudio.TeamFoundation.Client")
[void] [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.VisualStudio.TeamFoundation.VersionControl")
$uri = [URI]"http://MyServer:8080/tfs/DefaultCollection"
$project = "MyProject"
$buildDefinition = "MyBuildDefinition"
# CONNECT
$collection = [Microsoft.TeamFoundation.Client.TfsTeamProjectCollectionFactory]::GetTeamProjectCollection($uri)
# BUILDS
$buildServer = $collection.GetService([Microsoft.TeamFoundation.Build.Client.IBuildServer])
$buildSpec = $buildServer.CreateBuildDetailSpec($project, $buildDefinition)
$ILinkingService = $collection.GetService([Microsoft.Teamfoundation.ILinking])
$CommonService = $collection.GetService([Microsoft.TeamFoundation.Common])
# QUERY
$buildSpec.InformationTypes = $null
$buildSpec.MaxBuildsPerDefinition = 5
$buildSpec.QueryOrder = [Microsoft.TeamFoundation.Build.Client.BuildQueryOrder]::FinishTimeDescending
$results = $buildServer.QueryBuilds($buildSpec)
foreach($build in $results.Builds)
{
Write-Host $build.Status
#$testUrl = $ILinkingService.GetArtifactUrl($build.Uri)
$testUrl = $CommonService.EncodeUri($build.Uri)
Write-Host $testUrl
}