I'm using the Microsoft.TeamFoundationServer.Client NuGet package for some custom scripting. I'd like to create branches in my TFS source control in VSTS, but I can't seem to find any functionality in this package to create any kind of branch, whether in TFVC or Git. Am I missing something or is the package ?
Assume you are using .NET client libraries for Visual Studio Team Services (and TFS). For TFVC, you need to use "Microsoft.TeamFoundation.VersionControl.Client". Following is the code sample:
using System;
using System.Collections.Generic;
using Microsoft.TeamFoundation.Client;
using Microsoft.TeamFoundation.VersionControl.Client;
namespace ConsoleApplica
{
class Program
{
static void Main(string[] args)
{
string URL = "https://xxxxx.visualstudio.com/";
TfsTeamProjectCollection ttpc = new TfsTeamProjectCollection(new Uri(URL));
VersionControlServer vcs = ttpc.GetService<VersionControlServer>();
string sourcepath = "$/ProjectNmae/SourceBranch";
string targetpath = "$/ProjectNmae/TargetBranch";
vcs.CreateBranch(sourcepath,targetpath,VersionSpec.Latest);
}
}
}
Update: For "Microsoft.TeamFoundationServer.Client", it access to VSTS via Rest API. However, the Rest API for TFVC and Git can only get the branches for now, it cannot create branch. So you cannot see the method in "Microsoft.TeamFoundationServer.Client" either.
Integrate with Team Foundation Server 2015 and Visual Studio Team Services from desktop-based, ASP.NET, and other Windows applications. Provides access to version control, work item tracking, build, and more via public REST APIs.