Reputation: 269
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"
Upvotes: 3
Views: 4045
Reputation: 3104
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.
Upvotes: 1
Reputation: 1408
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.
Upvotes: 1
Reputation: 28970
You can follow theses steps - based on VersionControlServer
class
Link : http://msdn.microsoft.com/fr-fr/library/bb138927.aspx
Note : Add reference on
Microsoft.TeamFoundation.VersionControl.Client.dll
Microsoft.TeamFoundation.Client.dll
Upvotes: 0