The following code works fine for .Net 4.8 with Nuget Microsoft.TeamFoundationServer.ExtendedClient Version="16.205.1"
using System;
using Microsoft.TeamFoundation.Client;
using Microsoft.TeamFoundation.VersionControl.Client;
using Microsoft.VisualStudio.Services.WebApi;
using Microsoft.VisualStudio.Services.Common;
namespace TfsWorkspaceGet
{
class Program
{
static void Main(string[] args)
{
// Create VSS credentials
VssBasicCredential vssCred = new VssBasicCredential(
"valid userid",
"valid PAT token");
// connect to TFS
var tfsCollection = new TfsTeamProjectCollection(new Uri("https://someorg.com/tfs/projects"));
tfsCollection.EnsureAuthenticated();
//connect to Azure DevOps using the basic credentials
var connection = new VssConnection(new Uri(tfsUrl), vssCred);
var versionControlServer = tfsCollection.GetService<VersionControlServer>();
// Create a workspace
Workspace workspace = versionControlServer.CreateWorkspace("tmpTfsWorkspace");
// Map the server path to the local path
workspace.CreateMapping(new WorkingFolder(
"$/SomProj/Mainline/DEV/SomeComponent",
@"D:\WS\SomProj\Mainline\DEV\SomeComponent"));
// Get the latest version
workspace.Get();
}
}
}
Am trying to get it upgraded to working with .Net 6+... unsuccessfully
connection.GetClient<TfvcHttpClient>
Though it does match for the Workspacesetup and get needsAny help or pointers on this?
I can reproduce the issue using your scripts. The reason of the issue is that the Microsoft.TeamFoundationServer.ExtendedClient
package doesn't support Net Standard Client OM.
According to .NET client libraries,
Microsoft.TeamFoundationServer.ExtendedClient: Work with and manage version control, work items, and build, and other resources from your client application. This package doesn't support Net Standard Client OM. Only use this package when our REST APIs don't offer the functionality you need (for example, creating workspaces in TFVC)
And
This package includes our older SOAP object model, which we replaced by our newer REST object model. We're no longer investing in the older SOAP object model, and have no plans to create a NetStandard version of it.
Based on the current situation, it's suggested that you keep .Net 4.8
.