문제

Question background:

I'm trying to do the following process but currently cannot succesfully map the TFS code to the specified local folder:

  1. Create a temporary work space.
  2. Set the temporay workspace to be on the C drive in a folder called 'BasicSccExample'
  3. From a passed object called 'vssItem', concatenate its 'VcQaFolder' and 'Name' properties to set the specified TFS server path.
  4. Map the TFS server path to the local path.
  5. Get the latest code from the TFS server.
  6. Create a folder called 'sub' within the 'BasicSccExample' Folder.
  7. Create the this new 'basic' folder.
  8. Check the differences between the local specified file copies.
  9. Delete the temporary workspace.

The code to carry out the above process:

Workspace workspace = tfServer.CreateWorkspace("BasicSccExample", tfServer.AuthorizedUser);

string topDir = null;

string result = null;

string localDir = @"c:\BasicSccExample";

string test = vssItem.VcQaFolder + "/"+vssItem.Name;

workspace.Map(test, localDir);

workspace.Get();

topDir = Path.Combine(workspace.Folders[0].LocalItem, "sub");

Directory.CreateDirectory(topDir);

var potentialDifference = Difference.DiffFiles(topDir, FileType.Detect(topDir, null), topDir, FileType.Detect(topDir, null), new DiffOptions());

result = potentialDifference.Next == null ? "Identical" : "Different";

workspace.Delete();

The error:

I always receive a null exception when attempting to compare the files - which for testing purpose at the moment are the same file. The reason for this error is because the specified local folder on the C drive that the code should be mapped too is always empty. Can anyone tell me where I'm going wrong?

도움이 되었습니까?

해결책

Sorted this issue out. I was trying to set the file as a folder.

For anyone out there with similar issues, check you're not making the same mistake and this code works .

I can now map from the specifed TFS server path to the specified local path.

Workspace workspace = tfServer.CreateWorkspace("TempDevWorkspace", tfServer.AuthorizedUser);

        string topDir = null;

        string localDir = @"c:\TempDevWorkspaceFolder";

        workspace.Map(tfsItem.VcDevFolder, localDir);

        workspace.Get();

        string directory = Path.Combine(workspace.Folders[0].LocalItem, null);
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top