using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.TeamFoundation.Client;
using Microsoft.TeamFoundation.Lab.Client;
namespace LabEnvironmentCreation
{
classProgram
{
staticvoid Main(string[] args)
{
//Get reference to lab service
TfsTeamProjectCollection tfsServer = newTfsTeamProjectCollection(TfsTeamProjectCollection.GetFullyQualifiedUriForName(“http://<ATName>:8080/tfs”));
LabService labService = (LabService)tfsServer.GetService(typeof(LabService));
//Create Lab System Definition List
List<LabSystemDefinition> lsdList = newList<LabSystemDefinition>();
LabSystemDefinition lsd = new LabSystemDefinition(“MachineName”, “LSDName”, “RoleOfMachine”);
lsd.Description = “Add Some Description”;
//Add Lab System to List
lsdList.Add(lsd);
//Create Lab Environment Definition
LabEnvironmentDefinition led = new LabEnvironmentDefinition(“EnvironmentName”, “Environment Description”, lsdList);
led.TestControllerName = “NameOfTestController:Port”; //Example <TCName>:6901
//Create Lab Environment
LabEnvironment Le = LabService.CreateLabEnvironment(“ProjectName”, led, null, null);
}
}
}
0 comments