Getting started with Microsoft Lab Management

The last couple of weeks I’ve gotten a number of questions on how to set up Microsoft Lab Management. The process is not trivial but the references below should get you started:

If you want to get started with Microsoft Lab Management then you can get a number of good starter videos here.

I can also recommend looking at the MSDN documentation on how to set to Lab Management, lots of good guidance and recommendations there.

I suggest working with someone with good knowledge of Windows Server and Hyper-V as well as the System Center Virtual Machine Manager. For a developer such as myself it can be quite overwhelming with all options in these products. It’s one thing to get a demo environment up and running but for a production environment you really should build the foundation right first. So team up with someone knowledgeable in the IT side and combine that with the test and development skills is my recommendation.

Browse items in TFS Version Control programmatically, reposted

I got a comment a while back that some articles on my old blog has broken links so I’m fixing that by reposting the updated articles here. This one is about using the TFS API to open a browser dialog from TFS 2008. The code still works with 2010 but there might be a better way to do that now but for now this is a working solution.


Ever wanted to use the TFS API to pull up a dialog to let a user browse the version control repository and select a file or a folder? Unfortunately it turns out there is no function to do so. Or atleast, no obvious way…


With pointers from Philip Kelley at Microsoft I learnt that inside the Microsoft.TeamFoundation.VersionControl.Controls assembly there’s a private class called DialogChooseItem that displays the following dialog:


ItemBrowser


In order to use that dialog we’ll have to invoke by using .NET reflection. The constructor can take either just the TFS to connect to (start at the root of the version control tree) or the folder and file to navigate to when the dialog is shown.


The key code to invoke the dialog is the following (based on Visual Studio 2008 SP1 and TFS 2008 SP1):


VersionControlServer versionControlServer = (VersionControlServer)tfs.GetService(typeof(VersionControlServer));
Assembly controlsAssembly = Assembly.GetAssembly(typeof(Microsoft.TeamFoundation.VersionControl.Controls.ControlAddItemsExclude)); 
Type vcChooseItemDialogType = controlsAssembly.GetType(“Microsoft.TeamFoundation.VersionControl.Controls.DialogChooseItem”);
ConstructorInfo ci = vcChooseItemDialogType.GetConstructor(
                   BindingFlags.Instance | BindingFlags.NonPublic,
                   null,
                   new Type[] { typeof(VersionControlServer) },
                   null);
_chooseItemDialog = (Form)ci.Invoke(new object[] { versionControlServer });
_chooseItemDialog.ShowDialog();
 this.DialogResult = _chooseItemDialog.DialogResult;


To get to the selected item access the SelectedItem property (again using .NET reflection):


_selectItemProperty = vcChooseItemDialogType.GetProperty(“SelectedItem”, BindingFlags.Instance | BindingFlags.NonPublic);
Item selectedItem = (Item)_selectItemProperty.GetValue(_chooseItemDialog, null);
selectedItem.ServerItem;


That’s it. With some simple .NET reflection magic we can now use the internal item brower dialog.


The complete sample can be downloaded here: ItemBrowser.zip (15,63 KB)


Update: a solution for Visual Studio 2010 cam be downloaded here: ItemBrowser-vs2010.zip (17,67 KB). 


Disclamer: the DialogChooseItem is an internal unsupported implementation. It may change at any time so if you use it your’re on your own.

Clone a Build Definition

In the September update of the TFS Power Tools a very handy feature for managing TFS build definitions was introduced. This feature saves time and reduces the risk for errors when managing build definitions. To clone a build definition all you need to do is to right-click on the source build definition in the Team Explorer and choose “Clone Build Definition”.

After you have cloned the build definition there are some things that needs to be fixed however:

  1. Clone build definition.
  2. Disable build definition to prevent accidental triggering.
  3. Rename the build definition.
  4. Change workspace mapping to new location (if needed).
  5. Change drop location (if needed).
  6. Change the process to point to the right projects/solutions (if needed).
  7. Enable the build definition.

Screenshots below to illustrate the process:

1. Clone build definition.

image

image

2. Disable build definition to prevent accidental triggering. Rename the build definition.

 image

3. Change workspace mapping to new location (if needed).

image

4. Change drop location (if needed).

image

5. Change the process to point to the right projects/solutions (if needed).

image

6. Enable the build definition.