This has nothing to do with WPF, but it was excessively difficult to find any useful information on the subject. I get the impression Microsoft has gone to great lengths to make you not want to do this.
Lets jump right in and write a console app that finds the most recent check in and lists it, together with the files that were modified.
Start a new project in Visual Studio. Chose C# console .Net Framework and call the project TFS.
Browse to Tools -> NuGet Package manager -> Manage NuGet packages for solution
Click the Browse tab and install Microsoft.TeamFoundationServer.ExtendedClient.
Add these usings to Program.cs
Now we need to figure out our server URL and path. Add two declarations to Main(). Yours will contain your server name and the path to your project or solution. My declarations look like this. If your tfs server uses https it would look more like https://tfs-back:443/...
string path = "$/Financial/Dev/";
TfsTeamProjectCollection tpc = new TfsTeamProjectCollection(new Uri(server), new VssCredentials(true));
VersionSpec.Latest,
deletionId: 0,
RecursionType.Full,
user: null,
new ChangesetVersionSpec(1),
VersionSpec.Latest,
maxCount: 1,
includeChanges: true,
slotMode: true))
{
Changeset changeSet = (Changeset)obj;
Console.WriteLine($"Changeset {changeSet.ChangesetId} {changeSet.CreationDate} {changeSet.CommitterDisplayName} {changeSet.Comment}");
foreach (Change change in changeSet.Changes)
Console.WriteLine($" {change.Item.ServerItem}");
}
$/Financial/Dev/Scripts/F2000Master_Database.sql
$/Financial/Dev/F2K.Net/Core/Database/Config/DistrictConfig.cs
Here's the code in its entirety.
namespace TFS
internal class Program
{
static void Main(string[] args)
string server = "http://tfs-back:8080/tfs/DefaultCollection";
TfsTeamProjectCollection tpc = new TfsTeamProjectCollection(new Uri(server), new VssCredentials(true));
foreach (object obj in vcs.QueryHistory(path,
RecursionType.Full,
includeChanges: true,
Changeset changeSet = (Changeset)obj;
Console.WriteLine($" {change.Item.ServerItem}");
}
Console.ReadLine();
}
}
No comments:
Post a Comment