Team Foundation Serverを使うようになってからもうかれこれ2年ぐらいが経つ。その間にだんだんソリューションファイルが多くなってきたり、一つの製品の開発環境を作るのにあっちをいじったりこっちをいじったりしなきゃいけなくなってきたので、自動化を試みている。その一環としてPowerShellを使ってTeam Foundation Serverから最新バージョンのコードをダウンロードするコードを書いてみた。

param
(
    $tfsServerName = $(Throw "TFSのサーバ名を入力してください。"),
    $localFolderPath = $(Throw "ローカルのフォルダパスを入力してください。"),
    $Domain = "",
    $Username = "",
    $Password = "",
    [String[]] $getPaths = $(Throw "サーバ側から最新コードをダウンロードするパスを配列として渡してください。")
)
 
[void] [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.TeamFoundation.Client")
[void] [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.TeamFoundation.VersionControl.Client")
 
$credential = $null
 
if (($Username -eq "") -or ($Password -eq ""))
{
    $credential = Get-Credential
}
else
{
    $credential = New-Object System.Net.NetworkCredential($Username, $Password, $Domain)
}
 
#TeamFoundationServerオブジェクトを作成。
$tfs = New-Object Microsoft.TeamFoundation.Client.TeamFoundationServer($tfsServerName, $credential)
$tfs.Authenticate()
 
# VersionControlServerを使ってWorkspaceオブジェクトを取得。
$vcs = $tfs.GetService([Microsoft.TeamFoundation.VersionControl.Client.VersionControlServer])
$ws = $vcs.GetWorkspace($localFolderPath)
 
$ws.Get($getPaths, [Microsoft.TeamFoundation.VersionControl.Client.VersionSpec]::Latest, "Full", "GetAll")
 

Posted in: PowerShell  Tags:

最新のブログ

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Calendar

«  11月 2008  »
月曜火曜水曜木曜金曜土曜日曜
272829303112
3456789
10111213141516
17181920212223
24252627282930
1234567
View posts in large calendar

Recent Posts

Recent Comments

Banners

Theme Grabber
Disclaimer
The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.

© Copyright 2009 PowerShell from Japan!!