[string]$tfsServer =
"http://vsalm:8080/tfs/FabrikamFiberCollection",
[string]$tfsLocation =
"$/MPPDemo/Calculator/CalcTest",
[string]$localFolder ="C:\test",
[string]$file,
[string]$checkInComments = "Checked in from
PowerShell"
)
$clientDll = "C:\Program Files (x86)\Microsoft Visual Studio
12.0\Common7\IDE\ReferenceAssemblies\v2.0\Microsoft.TeamFoundation.Client.dll"
$versionControlClientDll = "C:\Program Files (x86)\Microsoft
Visual Studio
12.0\Common7\IDE\ReferenceAssemblies\v2.0\Microsoft.TeamFoundation.VersionControl.Client.dll"
$versionControlCommonDll = "C:\Program Files (x86)\Microsoft
Visual Studio
12.0\Common7\IDE\ReferenceAssemblies\v2.0\Microsoft.TeamFoundation.Common.dll"
#Load the Assemblies
[Reflection.Assembly]::LoadFrom($clientDll)
[Reflection.Assembly]::LoadFrom($versionControlClientDll)
[Reflection.Assembly]::LoadFrom($versionControlCommonDll)
#Set up connection to TFS Server and get version control
$tfs =
[Microsoft.TeamFoundation.Client.TeamFoundationServerFactory]::GetServer($tfsServer)
$versionControlType =
[Microsoft.TeamFoundation.VersionControl.Client.VersionControlServer]
$versionControlServer = $tfs.GetService($versionControlType)
#Create a "workspace" and map a local folder to a TFS
location
$workspace =
$versionControlServer.CreateWorkspace("PowerShell
Workspace",$versionControlServer.AuthenticatedUser)
$workingfolder = New-Object
Microsoft.TeamFoundation.VersionControl.Client.WorkingFolder($tfsLocation,$localFolder)
$workspace.CreateMapping($workingFolder)
Get-ChildItem $localFolder -recurse | Foreach-Object {
$file = $_.FullName
$workspace.PendAdd($file)
}
#Submit file as a Pending Change and submit the change
$pendingChanges = $workspace.GetPendingChanges()
$workspace.CheckIn($pendingChanges,$checkInComments)
#Delete the temp workspace
$workspace.Delete()
0 comments:
Post a Comment