Skip to content

Instantly share code, notes, and snippets.

@dieseltravis
Created July 16, 2010 22:29
Show Gist options
  • Select an option

  • Save dieseltravis/479010 to your computer and use it in GitHub Desktop.

Select an option

Save dieseltravis/479010 to your computer and use it in GitHub Desktop.
.net console apps that get a list of files changed by me
using System;
//Microsoft.TeamFoundation.Client.dll
using Microsoft.TeamFoundation.Client;
//Microsoft.TeamFoundation.VersionControl.Client.dll
using Microsoft.TeamFoundation.VersionControl.Client;
namespace GetPendingChanges
{
class Program
{
const string TFSSERVER = "http://TfsServer:8080";
static void Main(string[] args)
{
string projectName = args[0];
TeamFoundationServer tfs = new TeamFoundationServer(TFSSERVER);
VersionControlServer versionControl = (VersionControlServer)tfs.GetService(typeof(VersionControlServer));
PendingSet[] sets = versionControl.GetPendingSets(new String[] { "$/Projects/" + projectName }, RecursionType.Full);
Console.WriteLine(versionControl.AuthenticatedUser + " pending changes for " + projectName + ":");
int total = 0;
foreach (PendingSet set in sets)
{
if (set.Type == PendingSetType.Workspace && set.OwnerName == versionControl.AuthenticatedUser)
{
foreach (PendingChange pc in set.PendingChanges)
{
Console.WriteLine(pc.ServerItem);
total++;
}
}
}
Console.WriteLine(total.ToString() + " total changes.");
}
}
}
using System;
using System.Linq;
//Microsoft.VisualStudio.SourceSafe.Interop.dll
using Microsoft.VisualStudio.SourceSafe.Interop;
namespace GetPendingCheckins
{
class Program
{
const string SSDIR = @"\\VssServer\VssShare";
static void Main(string[] args)
{
string projectName = args[0];
string userName = "user";
string vssPath = SSDIR;
VSSDatabaseClass vss = new VSSDatabaseClass();
vss.Open(vssPath + @"\srcsafe.ini", userName, userName);
VSSItem sourceItem = vss.get_VSSItem("$/Projects/" + projectName, false);
Console.WriteLine(userName + " pending checkins for " + projectName + ":");
int total = GetItems(sourceItem);
Console.WriteLine(total.ToString() + " total changes.");
}
const int VSSFILE_CHECKEDOUT_ME = 2;
const int VSSITEM_PROJECT = 0;
const int VSSITEM_FILE = 1;
public static int GetItems(IVSSItem originalItem)
{
int total = 0;
foreach (IVSSItem subItem in originalItem.get_Items(false))
{
if (subItem.Type == VSSITEM_FILE && subItem.IsCheckedOut == VSSFILE_CHECKEDOUT_ME)
{
Console.WriteLine(subItem.Spec);
total++;
}
else if (subItem.Type == VSSITEM_PROJECT)
{
total += GetItems(subItem);
}
}
return total;
}
}
}
@dieseltravis

Copy link
Copy Markdown
Author

Add the compiled EXEs to your External Tools in VS, pass in $(TargetName) and/or Prompt for arguments and send it to the Output window.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment