public TaskGroup CreateTaskGroup() { string projectName = ClientSampleHelpers.FindAnyProject(this.Context).Name; // Get a task agent client instance VssConnection connection = Context.Connection; TaskAgentHttpClient taskClient = connection.GetClient <TaskAgentHttpClient>(); Dictionary <string, string> inputs = new Dictionary <string, string>() { { "scriptType", "inlineScript" }, { "inlineScript", "Write-Host \"Hello World\"" }, }; // Task inside the task group TaskGroupStep taskGroupStep = new TaskGroupStep() { Enabled = true, DisplayName = "PowerShell Script", Inputs = inputs, Task = new TaskDefinitionReference { Id = new Guid("e213ff0f-5d5c-4791-802d-52ea3e7be1f1"), VersionSpec = "1.*", DefinitionType = "task" }, }; // Task group object TaskGroupCreateParameter taskGroup = new TaskGroupCreateParameter() { Category = "Deploy", Name = "PowerShell TG1", InstanceNameFormat = "Task group: TG", Version = new TaskVersion { IsTest = false, Major = 1, Minor = 0, Patch = 0 } }; taskGroup.Tasks.Add(taskGroupStep); // Create task group TaskGroup addedTg = taskClient.AddTaskGroupAsync(project: projectName, taskGroup: taskGroup).Result; this.addedTaskGroupId = addedTg.Id; // Show the added task group Context.Log("{0} {1}", addedTg.Id.ToString().PadLeft(6), addedTg.Name); return(addedTg); }