3

I wrote some codes for get latest version of selected project. When I run it, it works. But if I delete the folder and run it again, it says "all files up to date"

I solved this problem with using Visual Studio TFS source kontrol and Get Specific version. How can I implement in C# project with TFS API?

My Code:

WorkingFolder workfolder = new WorkingFolder(ServerFolder, LocalFolder);
workspace.CreateMapping(workfolder);

workspace.Get(VersionSpec.Latest, GetOptions.Overwrite);

Edit:

I add that code and check returned value "getStatus"

GetStatus getStatus = workspace.Get(VersionSpec.Latest,  GetOptions.Overwrite);
if (getStatus.NoActionNeeded)
// create new workspace and use same codes in "My code"
mozkarakoc
  • 269
  • 6
  • 14

3 Answers3

1

I haven't been about to try this out, but can you combine GetOptions.Overwrite with GetOptions.GetAll?

workspace.Get(VersionSpec.Latest, GetOptions.Overwrite | GetOptions.GetAll)

From the command line, I'd use the /force option for the tf get command. I think the GetOptions.GetAll flag may be equivalent to the /force option.

Dan Shield
  • 1,358
  • 7
  • 14
  • Thanks, I tried it. I add "GetOptions.GetAll" in my code and when I click the get latest button, program is downloading all project in my workspace. I want to get only selected project at treeView – mozkarakoc Sep 14 '12 at 06:31
1

If you are using a local workspace in 2012 then the issue of GetLatest not downloading files you have deleted will not be a problem. However, in a "server" workspace, TFS only knows about the changes to your local disk that you have told TFS about. In this case, since the TFS server doesn't know about the files that you deleted, it won't know that they are missing and won't redownload them.

If you want to get them in this case, you would have to pass the force option like Dan mentions. Force isn't a great option to pass all of the time though. It will force all content to be redownloaded which is soemthing you usually do not want to do.

Taylor Lafrinere
  • 3,084
  • 18
  • 27
  • 1
    Thanks Taylor, your explanation was very informative. I solved problem using GetStatus class. After calling workspace.Get() method, I check returned value and if value is "NoActionNeeded" I get all. Thanks again. – mozkarakoc Sep 14 '12 at 11:01
0

You can follow theses steps - based on VersionControlServer class

Link : http://msdn.microsoft.com/fr-fr/library/microsoft.teamfoundation.versioncontrol.client.versioncontrolserver.aspx

Link : http://msdn.microsoft.com/fr-fr/library/bb138927.aspx

Note : Add reference on

Microsoft.TeamFoundation.VersionControl.Client.dll 

Microsoft.TeamFoundation.Client.dll
Aghilas Yakoub
  • 28,516
  • 5
  • 46
  • 51