I am automating a TFS branching process with DotNet core 2.2. We are using TFS 2018.
How can I create a new branch in TFS source control using C#?
I have been able to queue a build a do some other operations.
Microsoft.TeamFoundation.VersionControl.Client.VersionControlServer
has a method for CreateBranch
but I have not been able to instantiate a VersionControlServer
. Old documentation shows this is done with TfsTeamProjectCollection
but I can't find any libraries with that class.
A lot of the MSDN documentation goes to obsolete or deprecated references.
UPDATE
I have found that TfsTeamProjectCollection is in MicrosoftTeamFoundationServer.ExtendedClient if I install version 14.83.0, but the current version is 16.143.2.
When I drop back to this old version I get runtime errors associated with versions of other packages. If I downgrade them there are several build errors so I will need to refactor. I can't downgrade, and shouldn't have to.
What has replaced this?
Update
For the test from my side, It works properly with .net framework project.
But not able to do with .net Core, it's even not able to restore related Nuget packages.
Yes, it's using namespace Microsoft.TeamFoundation.VersionControl.Client
and Assembly: Microsoft.TeamFoundation.VersionControl.Client
Sample code for your reference:
var server = new TfsTeamProjectCollection(accountUri, new VssBasicCredential(string.Empty, personalAccessToken));
var vcServer = server.GetService<VersionControlServer>();
var changesetId = vcServer.CreateBranch("$/Demo/Main","$/Demo/Dev/Branch", VersionSpec.Latest, null, "Branch Comment", null, null, null);
You could see the official documentation for this class at: VersionControlServer Class
To get this Microsoft.TeamFoundation.VersionControl.Client.dll
, it has been been moved into a Nuget package--Microsoft.TeamFoundationServer.ExtendedClient.
Take a look at this similar question here: Where can I find Microsoft.TeamFoundation.VersionControl.Client.dll in Visual Studio 2015 installation?