0

I'm using the .NET libraries provided by Microsoft for interaction with Visual Studio Team Services. I want to be able to change the local path of the working folder without using Team Foundation Power Tools or Visual Studio, only using the class library i'm making.

The problem is changes aren't being recognized by the source control in the new location. I can see the new working folder through the Power Tools menu for workspaces but it doesn't automatically detect changes inside that working folder.

This is my code for this functionality:

this.workingFolder = new WorkingFolder(this.workingFolder.ServerItem, newLocalFolder);
            workspace.CreateMapping(workingFolder);
            UpdateWorkspace();

public int UpdateWorkspace()
        {
            // Check if user has read permissions.
            CheckWorkspacePermissions();
            // Update the workspace with most recent version of the project files from the repository.
            GetStatus status = workspace.Get();
            Console.Write("Conflicts from checkout: ");
            Console.WriteLine(status.NumConflicts);
            return status.NumConflicts;
        }

I'm clueless. The documentation for these .NET libraries is practically non-existent so i have no idea why this isn't working.

EDIT: Seems it started working after i did a refactoring of my code. The existence of conflicts also plays a role in things not working, sometimes.

Community
  • 1
  • 1
sonicadv27
  • 41
  • 7
  • I can't reproduce this issue, the new files and modified files can be detected. Do you mean it says "No changes to check in" when check in changes through Power Tools. Does the changes can be detected in the old working folder? What's the result if you try it with a new workspace? – starian chen-MSFT Jun 20 '17 at 08:16
  • Yes, when i try to check in it says there are no changes to check in. – sonicadv27 Jun 20 '17 at 08:41
  • Does the changes can be detected in the old working folder? What's the result if you try it with a new workspace? – starian chen-MSFT Jun 20 '17 at 08:45
  • What file you modified? Is it a new file you created after change mapping folder? – starian chen-MSFT Jun 20 '17 at 08:46

1 Answers1

1

With below code, it can change a TFVC repo (TryTFVC) map path, such as change from C:\Users\TFSTest\Source\Workspaces\G1\TryTFVC to C:\Users\TFSTest\Source\Workspaces\G1\1:

NetworkCredential cred1 = new NetworkCredential("alternate credential username", "alternate credential password");
TfsTeamProjectCollection tpc = new TfsTeamProjectCollection(new Uri("https://account.visualstudio.com"), cred1);
VersionControlServer versionControl = tpc.GetService<VersionControlServer>();
Workspace ws = versionControl.GetWorkspace(@"C:\Users\TFSTest\Source\Workspaces\G11\TryTFVC");//older path
WorkingFolder wf = new WorkingFolder("$/TryTFVC", @"C:\Users\TFSTest\Source\Workspaces\G1\1");
ws.CreateMapping(wf); //map with new path
ws.Get();

GetStatus status = ws.Get();
Console.Write("Conflicts from checkout: ");
Console.WriteLine(status.NumConflicts);
Marina Liu
  • 36,876
  • 5
  • 61
  • 74