3

I've got this nuget package (and the non-extended one): https://www.nuget.org/packages/Microsoft.TeamFoundationServer.ExtendedClient/

Which I'm seeing references to as a replacement for Microsoft.TeamFoundation.VersionControl.Client.dll. Unfortunately, I'm trying to access the Microsoft.TeamFoundation.VersionControl namespace, and it doesn't seem to exist. I see entries for Git and SourceControl, but VersionControl is throwing a "The type or namespace name 'VersionControl' does not exist in the namespace 'Microsoft.TeamFoundation' (are you missing an assembly reference?)" and Intellisense isn't suggesting anything else for Using statements regarding VersionControlServer and so forth.

My intention is to have an automation server pull down a workspace, manipulate some files, and upload to a new workspace, using TFVC with an access token. I have the rest of the logic worked out and written, but the "missing" reference is just causing issues.

I'm not really seeing any documentation about where it might have gone either. Any ideas?

user1874135
  • 419
  • 5
  • 17

4 Answers4

2

There isn’t Microsoft.TeamFoundation.VersionControl namespace, also there isn’t VersionControl class, the VersionControlServer is in Microsoft.TeamFoundation.VersionControl.Client namespace.

The simple sample to create workspace and add a file and check in:

 NetworkCredential cred = new NetworkCredential("[account name]", "[person access token]");
             TfsTeamProjectCollection tpc = new TfsTeamProjectCollection(new Uri("https://[xxx].visualstudio.com"), cred);
            tpc.EnsureAuthenticated();
            VersionControlServer versionControl = tpc.GetService<VersionControlServer>();
Workspace workspace = versionControl.CreateWorkspace("TestWorkspace", versionControl.AuthorizedUser);
try
            {
                String localDir = @"c:\temp\BasicSccExample";
                //Console.WriteLine("\r\n--- Create a mapping: {0} -> {1}", args[1], localDir); 
                workspace.Map("$/Agile2015/APIFolder", localDir);


                workspace.Get();

                Console.WriteLine("\r\n--- Create a file.");
                topDir = Path.Combine(workspace.Folders[0].LocalItem, "sub");
                Directory.CreateDirectory(topDir);
                String fileName = Path.Combine(topDir, "basic.txt");
                using (StreamWriter sw = new StreamWriter(fileName))
                {
                    sw.WriteLine("revision 1 of basic.txt");
                }

                Console.WriteLine("\r\n--- Now add everything.\r\n");
                workspace.PendAdd(topDir, true);

                Console.WriteLine("\r\n--- Show our pending changes.\r\n");
                PendingChange[] pendingChanges = workspace.GetPendingChanges();
                Console.WriteLine("  Your current pending changes:");
                foreach (PendingChange pendingChange in pendingChanges)
                {
                    Console.WriteLine("    path: " + pendingChange.LocalItem +
                                      ", change: " + PendingChange.GetLocalizedStringForChangeType(pendingChange.ChangeType));
                }

                Console.WriteLine("\r\n--- Checkin the items we added.\r\n");
                int changesetNumber = workspace.CheckIn(pendingChanges, "Sample changes");
                }
starian chen-MSFT
  • 33,174
  • 2
  • 29
  • 53
  • I can't access Microsoft.TeamFoundation.VersionControl.Client because I can't access Microsoft.TeamFoundation.VersionControl - my Using statement is for Client, but the error being thrown is that VersionControl does not exist in the namespace Microsoft.TeamFoundation, hence the wording in the question. Thanks though, it is good confirmation that I've got the rest of it set up right :) – user1874135 Oct 04 '16 at 14:20
  • @user1874135 Click References to expand references after install Microsoft.TeamFoundationServer.ExtendedClient package, then check whether there is Microsoft.TeamFoundation.VersionControl.Client reference, if not, re-install ExtendedClient package or create new application and install that package. – starian chen-MSFT Oct 05 '16 at 03:11
1

If I undestood you correctly: Just download the nuget package into a new empty project. You'll see that the namespace is there. Maybe you are shadowing the namespace by having your own namespace contain part of the one you're trying to reference, like for example you maybe have:

namespace My.Microsoft.TeamFoundation.VersionControl 
{
    // ... your code ...
}

In which case you should change your namespace name, or use "global::" (https://msdn.microsoft.com/en-us/library/c3ay4x3d.aspx).

Fredy Treboux
  • 3,167
  • 2
  • 26
  • 32
  • I just double checked and I'm not seeing any matching namespaces in my code, but it could potentially be something borked in my references causing a collision. I'll try the new project and global options tomorrow morning. – user1874135 Oct 04 '16 at 00:37
1

It is in the Microsoft.TeamFoundation.VersionControl.Client namespace. I have these nuget packages installed:

Microsoft.TeamFoundationServer.Client
Microsoft.TeamFoundationServer.ExtendedClient

Both Version 14.102.0

JBrooks
  • 9,901
  • 2
  • 28
  • 32
0

Tested a new project per Fredy Treboux's suggestion and it worked there.

At that point I completely uninstalled all TFS and VS Services-related packages and ensured all files were deleted for them, then reinstalled. Seems to have fixed it, all references are pulling through without error now.

user1874135
  • 419
  • 5
  • 17