Get information from Team Foundation Server (TFS) via C# code

This code shows you how you could interact with your team foundation server. In my case a TFS 2010.

Open a new console application in Visual Studio and add these references:

  • Microsoft.TeamFoundation.Client
  • Microsoft.TeamFoundation.VersionControl.Client
TeamFoundationServer tfs = new TeamFoundationServer("http://yourtfsserver:port/something");
List<string> changedFiles = new List<string>();

VersionControlServer VCServer = (VersionControlServer)tfs.GetService<VersionControlServer>();

try
{
string path = @"C:\Users\<username>\Documents\Visual Studio 2010\Projects\just the path to your solution";
VersionSpec version = VersionSpec.Latest;
int deletionId = 0;
RecursionType recursion = RecursionType.Full;
string user = @"domain\yourusername";

foreach (Changeset item in VCServer.QueryHistory(path, version, deletionId, recursion, user, null, null, Int32.MaxValue, true, false, true))
{
  foreach (Change c in item.Changes)
  {
	// c.Item.ServerItem;
  }
}
}
catch { }

Happy coding ;)

C# Linq: Zip method

string[] brands = new string[] { "BMW", "Mercedes", "Audi" };
string[] websites = new string[] { "www.bmw.com", "www.mercedes.com", "www.audi.com" };

var output = brands.Zip(websites, (b, w) => string.Format("{0} can be found at {1}", b, w));

foreach (var line in output)
  Console.WriteLine(line);

This gives you:

BMW can be found at www.bmw.com 
Mercedes can be found at www.mercedes.com 
Audi can be found at www.audi.com

More information at: http://msdn.microsoft.com/en-us/library/dd267698.aspx

Rx (Reactive Extensions)

Reactive Extensions (Rx) was added to Codeplex.com:

The project is actively developed by the Microsoft Open Technologies, inc., in collaboration with a community of open source developers.

The Reactive Extensions (Rx) is a library for composing asynchronous and event-based programs using observable sequences and LINQ-style query operators. Using Rx, developersrepresent asynchronous data streams with Observables , query asynchronous data streams usingLINQ operators, and parameterize the concurrency in the asynchronous data streams usingSchedulers. Simply put, Rx = Observables + LINQ + Schedulers.

Find out more on: https://rx.codeplex.com/

All-In-One Script Framework

Microsoft All-In-One Script Framework is an automation script sample library for IT Professionals.  The key value that All-In-One Script Framework is trying to deliver is Scenario-Focused Script Samples driven by IT Pros’ real-world pains and needs.  The team is monitoring all TechNet forums, IT Pros’ support calls to Microsoft, and will start to monitor the script requests submitted to TechNet Script Repository soon. We collect frequently asked IT scenarios, and create script samples to automate the tasks and save some time for IT Pros. The team of All-In-One Script Framework sincerely hope that these customer-driven automation script samples can help our IT community in this script-centric move.

Find out more on: http://blogs.technet.com/b/onescript/