Reputation: 15
I have a requirement to checkout and checkin file from TFS programmatically using c#. The code which I am using is as shown below.
var tfs = new TfsTeamProjectCollection(new Uri("http://MyTFSServer/"));
var versionControlServer = tfs.GetService<VersionControlServer>();
var workspace = versionControlServer.GetWorkspace(@"D:\Projects\");
var file = @"D:\Projects\Test.txt";
workspace.PendEdit(file);
using (StreamWriter sw = new StreamWriter(file))
{
sw.WriteLine("Test");
}
var pendingChange = workspace.GetPendingChanges();
var changesetNumber = workspace.CheckIn(pendingChange, "checkedin the file programmatically");
But when I execute this code, I am getting a CheckinException - TF10141: No files checked in: resolve the conflicts and try again. in the line workspace.CheckIn(pendingChange, "checkedin the file programmatically");
How can I fix this issue?
Upvotes: 0
Views: 8134
Reputation: 3352
As the others have said, there is a conflict here. That can occur by pending a change on a version of the file that is not the latest and trying to check in. You can see the conflicts with QueryConflicts. You can also find a sample here.
Upvotes: 1