I'm using the .NET Client Libraries for VSTS/TFS 2015 to programmatically create a build definition based off of a template that I've grabbed in another team project.
I can get a build definition template (2.0) by using:
BuildDefinitionTemplate builddeftemplate = buildHttpClient.GetTemplateAsync(teamProject, templateId).Result;
And I can create a build definition by using:
BuildDefinition builddef = new BuildDefinition();
builddef.Project = newTeamProject;
But there doesn't look like a way to pass in a template as a property of the build definition, nor create a build definition from the template.
When looking at the documentation for the REST API, the GET request actually looks like it returns a lot of JSON:
{
"id": "vsBuild",
"name": "Visual Studio",
"canDelete": false,
"category": "Build",
"iconTaskId": "71a9a2d3-a98a-4caa-96ab-affca411ecda",
"description": "Build and run tests using Visual Studio. This template requires that Visual Studio be installed on the build agent.",
"template": {
"build": [
{
"enabled": true,
"continueOnError": false,
"alwaysRun": false,
"task": {
"id": "71a9a2d3-a98a-4caa-96ab-affca411ecda",
"versionSpec": "*"
},
"inputs": {
"solution": "**\\*.sln",
"msbuildLocation": "",
"vsLocation": "",
"msbuildArgs": "",
"platform": "$(BuildPlatform)",
"configuration": "$(BuildConfiguration)",
"clean": "false"
}
},
...
So I think that it might be possible to only grab parts of the returned template as a JSON object and pass through a POST of the build definition with those parts, but it seems like that would have to solely be the REST API route.
Is this possible with the .NET Client Libraries? Or is there an easier way that I might have missed?