Reputation: 2183
I'm building a base developer machine image such that when a new developer is added to the team, we can give the developer a machine which has all the tools installed and configured.
I'm trying to devise a way to connect Visual Studio to TFS via a PowerShell script or command line batch file, such that visual studio will use the developer's credentials to connect to the TFS server.
I understand that the new developer can open up visual studio, open up the Team
menu, select connect to team foundation server...
Add a Server to the Servers...
dialog, then select the Team Projects
and click Connect
. However, this whole process is the process I'd like to automate.
I'm not looking for the code to do so, although it would be accepted. Instead, I'm looking for direction on where to locate the API calls for Visual Studio to modify this type of setting.
Upvotes: 3
Views: 1041
Reputation: 5558
You can use the following code to do this:
# Add servers to vs 2012
Add-Type -AssemblyName 'Microsoft.TeamFoundation.Client, Version=11.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'
function Add-Collection([string]$url) {
$uri = New-Object Uri($url)
$ttpc = New-Object Microsoft.TeamFoundation.Client.TfsTeamProjectCollection($uri)
$projs = [Microsoft.TeamFoundation.Client.RegisteredTfsConnections]::RegisterProjectCollection($ttpc)
}
Add-Collection -url 'http://mytfsserver:8080/tfs/DefaultCollection'
Note: if you have both VS 2010 and 2012 installed this will only add the registration to 2012.
Upvotes: 2