vs2013使用PowerShell创建到新源位置的映射

时间:2018-03-26 14:50:54

标签: powershell visual-studio-2013

我一直在尝试自动化本地安装Visual Studio(2013)工作区。我已经能够使用PowerShell建立与源位置的连接,但我无法获取要应用的本地映射。如果我手动映射源位置,我可以使用PowerShell获取本地映射。我从其他Stack Overflow线程中大量借用,但我无法找到一种方法来映射TFS服务器并将本地路径映射到工作区。谢谢!

clear host

[string]$TfsUrl = 'https://xxxx.visualstudio.com'

'.Client', '.VersionControl.Client', '.VersionControl.Common', '.WorkItemTracking.Client', '.Build.Client', '.Build.Common' |
ForEach-Object {
    Add-Type -AssemblyName "Microsoft.TeamFoundation$_, Version=12.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
}

try
{
    $uri = New-Object System.Uri -ArgumentList $TfsUrl
    $credentialProvider = new-object Microsoft.TeamFoundation.Client.UICredentialsProvider
    $collection = [Microsoft.TeamFoundation.Client.TfsTeamProjectCollectionFactory]::GetTeamProjectCollection($uri, $credentialProvider)    
    $collection.Authenticate()

    if ($collection.HasAuthenticated)
    {
        Write-Host -ForegroundColor Green 'Connection to TFS Successful'
        $tfs = '' | Select-Object Collection, VersionControlServer, WorkItemStore, BuildServer, IdentityManagementService        
        $tfs.Collection = $collection

        $tfs
    }
}
catch
{
    Write-Host -ForegroundColor Red $_.Exception.Message
    Write-Host
    Write-Host -ForegroundColor Red 'Failed to connect to TFS'
}

$tfsServer = "https://xxxx.visualstudio.com"
$computerName = [system.environment]::machinename
$folderName = "C:\VSTS_WB\xxxx.DuckCreek"; 

$dir = 'C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\'
Set-Alias tf "$dir\tf.exe"

new-item -itemtype directory -path $folderName -force

cd $folderName

tf workfold "$/xxxx.DuckCreek" $folderName /map

tf workfold "$/xxxx.DuckCreek/BR1/Policy/Source" "C:\Program Files\Duck Creek Technologies" /map

tf workfold "$/xxxx.DuckCreek/BR1/Policy/Source/Shared.x86" "C:\Program Files (x86)\Duck Creek Technologies" /map

tf workfold "$/xxxx.DuckCreek/BR1/Billing/Source" "C:\Program Files\Duck Creek Technologies Billing" /map

0 个答案:

没有答案
相关问题