I'm using BuildHttpClient's .GetDefinitionAsync and .CreateDefinitionAsync to clone a VSTS Build Definition. This works fine but I'd like to create the build defs in a different folder, other than the root folder of the project. I can add a folders via the "Manage Folders" link web but how can I do this programatically?
I've tried the following:
buildDef = JsonConvert.DeserializeObject<BuildDefinition>(json);
buildDef.BuildNumberFormat = buildNumFormat;
buildDef.Name = newBuildDefName;
Uri tfsURI = new Uri(CollectionReleaseURL);
buildDef.Url = tfsURI.ToString();
await buildClient.CreateDefinitionAsync(buildDef, project);
Where the Collection release is the path: CollectionReleaseURL = @"http://my.tfs.server8080/tfs/DefaultCollection/Project/Product/Release";
but when I run the program it just puts the new build def in the following folder: @"http://my.tfs.server8080/tfs/DefaultCollection/Project"
How can i clone the build def to the ../Product/Release folder?
UPDATE: I'm using the following to Clone the build def but it is NOT copying the Build Steps! Anyone know why that is?
private static async Task CloneBuildDefAsync(int buildDefId, string newBuildDefName, string buildNumFormat, string sourceControlPath, string URLpath)
{
var buildClient = createClient();
var buildDef = (await buildClient.GetDefinitionAsync(project, buildDefId)) as BuildDefinition;
buildDef.Project = null;
var json = JsonConvert.SerializeObject(buildDef);
json = json.Replace(sourceControlMainline, sourceControlPath);
buildDef = JsonConvert.DeserializeObject<BuildDefinition>(json);
buildDef.BuildNumberFormat = buildNumFormat;
buildDef.Name = newBuildDefName;
buildDef.Path = URLpath;
await buildClient.CreateDefinitionAsync(buildDef, project);
}
Seems to copy everything but the build step, everything else is cloned and updated perfectly: