11 March 2010

Adding Properties to Artifacts within TFS 2010

As you know, you can store a lot of information within Team Foundation Server – in the form of Work Items and Versioned Items (e.g. source code).  While these are great features within TFS there are times when you want to store other types of information within TFS and/or “tag” existing items with custom information.  For example, if you create a Visual Studio add-in for TFS, you might want to store the add-in’s properties within TFS such that they “follow” the developer from machine to machine – or - maybe you want to store some custom information with a specific changeset?

To help with the above scenarios (and many others) Team Foundation Server 2010 introduces the concept of Properties.  There are several types (Artifact Kinds) of properties defined within TFS (this set of properties can be expanded as well) and, depending upon the type, they are accessed in different ways.  The default set of Artifact Kinds include:

  • Version Control
    • Changeset
    • Versioned Item
    • Pending Change
    • Annotation (no longer used)
  • Framework
    • Generic (at Project Collection or Configuration Server)

Of the above Artifact Kinds, those listed under Version Control are considered to be “Internal”.  Internal properties can only be accessed by the service-specific APIs they are associated with (e.g. VersionControlServer).  As such, access to these properties are secured by the artifact they are associated with (e.g. a versioned file within TFS).

The Generic Artifact Kind is not considered to be internal.  Generic properties are accessed via the IPropertyService interface.  Unlike internal properties, there is no access control mechanism for generic properties.

Identifying Properties

Properties are identified by an ArtifactSpec. There are three constructor overloads including:

  • ArtifactSpec(Guid kind, int artifactId, int version);
  • ArtifactSpec(Guid kind, byte[] artifactId, int version);
  • ArtifactSpec(Guid kind, string moniker, int version);

In the case of internal properties, you don’t care much about the ArtifactSpec because it is hidden by the service-specific APIs.  For Generic (non-internal) properties, you will need to define an ArtifactSpec.  You can use any of the above constructors when creating an ArtifactSpec for a Generic property but the 3rd one (with the moniker parameter) seems like it would be the most common choice.

Generic Property Example:

Here is a simple example for setting a Generic property:

public void SetGenericProperty(bool isInstanceProperty, string moniker, int version, string propertyName, string propertyValue)
{
IPropertyService propertyService;

if (isInstanceProperty)
{
propertyService = _tpc.ConfigurationServer.GetService<IPropertyService>();
}
else
{
propertyService = _tpc.GetService<IPropertyService>();
}

ArtifactSpec artifactSpec = new ArtifactSpec(ArtifactKinds.Generic, moniker, version);

propertyService.SetProperty(artifactSpec, propertyName, propertyValue);
}

Notice the “if” check on line 5.  Here we’re checking to see if the Generic property should be stored at the Configuration Server (i.e. “instance”) or stored at the Project Collection.  If you want your property accessible across multiple project collections, store it at the Configuration Server.

Using the above method, here’s an example call to store this blog’s URL:

SetGenericProperty(false, "A Developer's Life", 1, "blog", "devmatter.blogspot.com");

In this example, the second parameter (“A Developer’s Life”) defines the moniker for this property.  In this case, the moniker groups a set of properties.  Grouping properties under a common moniker allows you to retrieve all (or a subgroup of) properties for a given moniker (e.g. using wildcards).  For example, here is a simple method for retrieving a list of Generic properties:

public IEnumerable<ArtifactInfo> GetGenericProperties(bool isInstanceProperty, string moniker, int version)
{
IPropertyService propertyService;

if (isInstanceProperty)
{
propertyService = _tpc.ConfigurationServer.GetService<IPropertyService>();
}
else
{
propertyService = _tpc.GetService<IPropertyService>();
}

ArtifactSpec artifactSpec = new ArtifactSpec(ArtifactKinds.Generic, moniker, version);
ArtifactPropertyValue[] values = propertyService.GetProperties(artifactSpec, null);

var props = new List<ArtifactInfo>();

foreach (var value in values)
{
foreach (var keyValue in value.PropertyValues)
{
props.Add(new ArtifactInfo()
{
Moniker = value.Spec.Moniker,
Version = value.Spec.Version,
Kind = value.Spec.Kind,
Id = value.Spec.Id,
PropertyName = keyValue.PropertyName,
PropertyValue = keyValue.Value.ToString(),
});
}
}

return props;
}

Just like in the “SetGenericProperty” example we’re checking whether to look for the properties at the Configuration Server or at the Project Collection.  Calling the method is also very simple:

var results = GetGenericProperties(false, "A Developer's Life", 1);

This call would return a list of all properties defined under the moniker “A Developer’s Life”.  Note that you can also make use of the wildcard characters ‘*’ and ‘?’ in the moniker.  For example:

This call would return the properties defined under the same moniker as above as well as any other moniker that starts with the text “A Dev”.

As with monikers, you can also apply filters the the property names themselves by using one of the overloaded versions of IPropertyService.GetProperties (line 15 above is using an overload that does not specify property filters).

A Property Browser

Unfortunately, there is no property “browser” built into Visual Studio/Team Explorer.  Therefore, I decided to create one to ease testing and querying of properties.  Although this utility is not 100% functional/complete, yet, I have uploaded the application source and binaries in their current state (you only need the EXE if you don’t care to look at the source code).  You can download the project from hereNOTE: you must have the Team Foundation 2010 Client installed for this utility to run.  The source code is part of a Visual Studio 2010 solution/project.  Once I’ve completed the project (i.e. fully implemented each of the property features) I will most likely upload the project to CodePlex or the MSDN Code Gallery.

When you first run the application, known as the “Artifact Property Browser”, you will be prompted to select a Project Collection:

Select Team Project Collection

Once you select a Project Collection, you will see something similar to this:

Artifact Property Browser

Notice the Artifact Type drop-down list – it currently lists Changeset, Generic, and Versioned Item (Pending Change is not yet implemented).  As you change the Artifact Type the various options will change depending upon the type selected.

To query properties:


  1. Select the desired Artifact Type

  2. Specify the appropriate values

  3. Click Search

For example, to see all Generic properties at the Project Collection level, enter the following values and click Search:


  • Artifact Type: Generic

  • Option: Moniker (Artifact ID (int) and Artifact ID (byte[]) is not yet implemented)

  • Moniker: * (wildcard character for all monikers)

  • Version: 1

  • Instance Property: Unchecked (check to see properties at the Configuration Server level)

Artifact Property Browser

Notice that we have one property defined, “blog”, with a value of “devmatter.blogspot.com”.

To add another Generic property, simply:


  1. Select the desired Artifact Type

  2. Specify the appropriate values in the Artifact Filter section (e.g. for Generic properties, set the Moniker and Version)

  3. Specify a property Name and Value in the Property section

  4. Click Set Value

Querying and setting properties for the other artifact types follow the same approach only the Artifact Filter settings change.  For example, querying Changeset properties looks something like this:

Artifact Property Browser

In this example, were querying all properties for Changeset number 3.

Querying Versioned Item properties looks like this:

Artifact Property Browser

In this example, we’re querying properties for all items that match the specified ItemSpec (in this case, a versioned folder) and VersionSpec (in this case “T” for “Latest” – click here for other examples).  We’ve also checked the “Recursive” option to retrieve properties for all items under the ItemSpec. (note: the properties shown above are set by TFS).

There are still quite a few examples that can be provided for the various property APIs (e.g. Versioned Item) that are not covered in this post.  I plan on creating a follow-up post in the near future.  In the meantime, download the provided source code for further examples.

Download the Artifact Property Browser and source code here.

Save on Visual Studio 2010 Professional and Pre-Order Now

Microsoft Visual Studio 2010 Professional will launch on April 12 but you can beat the rush and secure your copy today by pre-ordering at the affordable estimated retail price of $549, a saving of $250.

If you use a previous version of Visual Studio or any other development tool then you are eligible for this upgrade. Along with all the great new features in Visual Studio 2010 (see www.microsoft.com/visualstudio) Visual Studio 2010 Professional includes a 12-month MSDN Essentials subscription which gives you access to core Microsoft platforms: Windows 7 Ultimate, Windows Server 2008 R2 Enterprise, and Microsoft SQL Server 2008 R2 Datacenter.

So visit http://www.microsoft.com/visualstudio/en-us/pre-order-visual-studio-2010 to check out all the new features and sign up for this great offer.

06 March 2010

TechEd 2010 Birds-of-a-Feather Proposals Being Accepted

The Birds-of-a-Feather (BOF) volunteer organizing team is now accepting proposals from discussion leaders for BOF sessions at Tech-Ed 2010 in New Orleans June 7-10.  BOF sessions are community-led open discussions on any technology related topic.  No code, no slides, just discussion. You don't have to be an expert on the topic, just passionate or knowledgeable enough to lead a discussion. There will also be a session moderator to help keep the discussion flowing smoothly.

To submit a proposal visit http://northamerica.msteched.com/Birds-of-a-Feather.  The deadline for proposal is Monday, April 5th. (Note: proposals are reviewed in the order submitted so the sooner the better.)

02 March 2010

Microsoft .NET Framework 4 Installation Failure

If you attempt to install the .NET Framework 4 (RC – not sure yet if this will be an issue at RTM) or Visual Studio 2010/Team Foundation Server 2010 RC (which will install the .NET Framework 4 as a dependency) and the Windows Update service is not running, the install will fail.

When installing Team Foundation Server 2010 without the Windows Update service running, then you may see a dialog like this one (assuming you don’t already have the .NET Framework 4 installed):

TFS 2010 Setup Error 

If you’re installing only the .NET Framework 4 without the Windows Update service running, then you may see a dialog like this one:

.NET Framework 4 Setup Error

If you get either of the above errors, make sure you have the Windows Update service enabled and running:

Windows Update Service

One other issue that may give you a similar installation error is related to non-Windows (e.g. Mac or Linux) partitions on your machine.  If you’re getting the above error when installing the .NET Framework 4 and the Windows Update service is running, check out this issue on Microsoft’s Connect site for details regarding another possible solution (note: this issue has been flagged as fixed for RTM).

25 February 2010

Ten Features in Visual Studio 2010 You May Not Know About

There are a LOT of new features coming in Visual Studio 2010.  Some of them are very big features (e.g. IntelliTrace, Microsoft Test Manager, etc.).  However, there are lots of smaller features that, even though small, are great additions to Visual Studio.

It would take a lot of time and space to list each and every new feature in Visual Studio 2010 so I’ve picked ten new features that I personally find interesting and outlined them below:

  1. Removing Recent Items – If you make use of the Recently Used List (RUL) in Visual Studio, then you’ve no doubt had items in this list that no longer exist on your file system.  Although there have been several custom Visual Studio add-ins created to allow you to clear the RUL, it has never been an inherent feature of Visual Studio – until now!

    With Visual Studio 2010 you can (finally) right-click an item within the RUL to get a context menu of which one of the options is Remove From List:

    image
  2. Pinning Solutions – Those with a keen eye may have noticed the “pin” icons in the above screen shot.  You can now pin items within the Recently Used List (RUL) to keep them from rolling off as other projects/solutions are opened.  To pin an item, simply hover over the item name and click the pin icon (the icon shows up when you hover over it).  To unpin an item, simply click the pin icon again.
  3. Search Installed Templates – Each time you create a new project in Visual Studio, you are presented with a plethora of project templates to choose from.  These range from ASP.NET Web Applications, Crystal Reports projects, Silverlight Applications, WPF Applications, and lots, lots more.  In fact, there are now so many templates to choose from (with even more available on-line) that just finding the template you want can take some time.

    With Visual Studio 2010, there is now a “Search Installed Templates” search box in the upper right-hand corner of the “Add New Project” dialog.  As you start typing in this box, the list of available templates will be filtered based on the text you specify.

    image
  4. Navigate To – As with the project templates above, it can also be time consuming just locating various classes, methods, etc. within your code base.  You can do a global search (e.g. Ctrl+F or Ctrl+Shift+F) but this search will also include comments, string literals, etc.  In Visual Studio 2010, you now have a feature called “Navigate To”.  You can access this feature by clicking on Edit->Navigate To or by pressing Ctrl+,.

    image

    As you start typing in the Search terms box, a list of classes, methods, etc. that match your query will be listed.  Note in the example above, you can also filter based on Pascal Casing by entering two or more capital letters (in the example above, “CT” returns items starting with an upper-case “C” and an upper-case “T”).  You can also enter multiple words separated by spaces to return items with those search terms anywhere within them.
  5. Floating Windows – Multiple monitors are more common today than ever before.  Another way to take advantage of multiple monitors with Visual Studio 2010 is “floating” document windows.  Once a window has been “floated”, it can be dragged out of the Visual Studio 2010 IDE and onto another monitor allowing you to take full advantage of all of your screen real estate.

    To “float” a document tab: 1) double-click the tab – or 2) right-click the tab and select “Float”.  You can re-dock the tab by right-clicking the floating window’s title bar and selecting “Dock as Tabbed Document”.
  6. Pinning DataTips – DataTips have been a feature of Visual Studio for a while now.  However, with Visual Studio 2010, you can now pin DataTips to a debugging session and add comments for later review.  This is a great feature if you want to keep some simple notes between debugging sessions (the pinned DataTips and comments persist even after you close and reopen Visual Studio).

    To pin a DataTip, start a debugging session and stop at a breakpoint.  While in the debug session, hover over a variable to view a DataTip:

    image  

    Next, click on the pin icon on the right:
     image
    Click on the double arrows on the right to drop-down the comment box.  Enter any text you’d like to persist with the pinned DataTip.

    Even though you can only pin DataTips and enter comments during a debugging session, you can still view the pinned DataTips from the last debugging session within your source code by hovering over the pin icon in the gutter of the source code pane.  See the pin icon in the screen shot below and the pinned DataTip information displayed on the right.
    image 
  7. Freeze/Thaw Threads – If you’ve ever been debugging an application with multiple threads running, you’ve no doubt ran into issues where your debugging session bounces around different threads making it difficult, at best, to follow the program flow.

    Visual Studio 2010 provides a new Threads pane (Debug->Windows->Threads) that provides, among many other options, the ability to freeze and thaw individual threads.  For example, in the screen shot below, the fourth thread down has been frozen (you can right-click and select Freeze or click on the Freeze icon on the toolbar). 

    image

    So, the next time you’re in a debugging session and other threads start taking control – just freeze them!
  8. Visual Studio Gallery – The Visual Studio Gallery has been around for a while but now it’s integrated within Visual Studio 2010.  To access the gallery, click on Tools->Extensions Manager.

    image

    You can view installed extensions or view a list of extensions available on-line.  As seen in the screen shot above, you can also search the list by typing into the search box.  You can also contribute your own extensions to the gallery as well.
  9. Quick Font Sizing – Anyone that’s ever done a presentation with Visual Studio has more than likely had to modify the font size in the code window (i.e. make it large enough to read from the back of the room).  Typically this is done by opening the Tools->Options dialog, selecting Fonts and Colors and modifying the font size.  Although this works, it’s not ideal.

    Now, in Visual Studio 2010, you can modify the font size directly from the code pane in one of two ways: 1) hold down Ctrl and scroll the mouse wheel up/down to increase/decrease the font size respectively, or 2) click on the zoom drop-down list in the lower left-hand corner of the code pane and select the zoom level:
    image
  10. Insert Documents to Right of Existing Tab – This is a simple feature but I’m happy it has been added.  In Visual Studio 2008, each time you open a new window (be it a class file, design form, or whatever) it is always added to the left of the tabs.  If you wanted your windows to be added to the right of the tabs, it was not an option – until now.  If you prefer to have your windows opened to the right of the tabs you can now enable this option by selecting the “Insert Documents to Right of Existing Tab” option within the Options dialog:

    image 

If this looks like a set of Visual Studio features you’d like to take advantage of, keep in mind that the current Visual Studio 2010 Release Candidate is available for download and ships with a “Go Live” license allowing you to use it within a production environment.

23 February 2010

Visual Studio Lab Management 2010 Update

A short while ago pricing details were released for Visual Studio 2010 and Team Foundation Server 2010.  We just got an update for Visual Studio Lab Management 2010 regarding shipping plans and pricing.  Here are the details:

What is Visual Studio Lab Management 2010?

Visual Studio Lab Management 2010 is a new offering in the Visual Studio 2010 release wave. Lab Management 2010 enables teams to configure and manage a virtual lab environment. Lab Management works with System Center Virtual Machine Manager for enabling teams to create environment templates, provision ring-fenced environments, and checkpoint those environments. Using Lab Management, you can accelerate setup, tear down and restoration of complex virtual environments to a known state for test execution and build automation. It extends build automation by automating virtual machine provisioning, build deployment and build verification in an integrated manner. It also enables testers to file rich bugs with links to environment checkpoints that developers can use to recreate complex environments, effectively reducing wasted time and resources in your development and test life cycle. Those checkpoints can be attached to bugs filed using the Microsoft Test Manager enabling the person fixing the bug to open the environment right to the appropriate point in the application flow.

Q: How will Visual Studio Lab Management 2010 Beta 2 or RC be supported going forward?
A: We will continue to support customers that have already gone live with Lab Management 2010 pre-release go-live licenses.

Q. What are the pricing details of Visual Studio Lab Management 2010?
A: Suggested FPP retail price for Visual Studio Lab Management 2010 is US$1,599. Of course, the majority of customers are likely to qualify for a lower price point based on volume licensing discounts. Feel free to share this data with your customers to help them budget for Lab Management. Lab Management 2010 will be priced as per physical processor (each processor of each lab server must be licensed for Visual Studio Lab Management 2010). Visual Studio 2010 Ultimate or Visual Studio Test Professional 2010 is required to manage lab environments.

Q: Have we changed our shipping plans for the general availability of Visual Studio Lab Management 2010?
A: Quality has always been and remains a top priority for Visual Studio. Being definitive about RTM dates is always very difficult and doubly so for brand new v1 products. For this reason, until we are very close, we generally only forecast release timeframes rather than specific dates. While it’s true, early on, we had hoped to release the new Lab Management product at the same time as the rest of Visual Studio 2010. It became clear through the Beta cycle that it was taking a bit longer to get sufficient, detailed feedback. Excitement has been very high but there’s also a huge amount of new value in the 2010 wave; we made the decision that it was better for Lab Management to ship a little later in the 2010 wave if that means we can incorporate additional feedback to ensure it’s the terrific product everyone wants it to be. 

Keep in mind, Visual Studio 2010 Lab Management can be deployed today with a Go Live license.

Related Links

Team Foundation Server Power Tools for TFS 2010 RC

If you’ve been trying out Team Foundation Server 2010 RC then you’ll be pleased to know that the Team Foundation Server Power Tools have been released for TFS 2010 RC.  This release contains mostly fixes and compatibility improvements for the RC.  The Team Members Power Tool is now functional as well – although if you’re not signed into Windows Communicator, it will display a dialog box alerting you that you’re not logged in (a minor annoyance).

You can download the TFS Power Tools 2010 RC on the Visual Studio Gallery - here.  If you’ve installed the beta version of the Power Tools, be sure to uninstall them before installing the latest version.

12 February 2010

Visual Studio 2010 and .NET Framework 4 Training Kit

The Visual Studio 2010 and .NET Framework 4 Training Kit has been updated for the recent Visual Studio 2010 Release Candidate.  There is a lot of great content in this update including the following technologies:

The download is about 200MB in size and can be downloaded from here.  Once you download, run the executable file to extract it to your hard drive and open the Default.htm file to get started.

10 February 2010

Visual Studio 2010 Licensing

We’ve seen the prices for Visual Studio 2010 but what about licensing?  If you’re interested in the finer details of how Visual Studio 2010 is licensed, then check out the Visual Studio 2010 Licensing Whitepaper (available in PDF and XPS formats).

This is a 33-page document covering the following areas of Visual Studio 2010:

  • How to Buy
  • Visual Studio 2010 Client Edition and MSDN Subscription Licensing
  • Visual Studio Team Foundation Server 2010 Licensing
  • Lab Management
  • Load Testing
  • IntelliTrace

I wish it didn’t take 33 pages to explain product licensing but at least there’s a document :-)

09 February 2010

Visual Studio/TFS 2010/.NET 4 RC Released

When Microsoft announced that Visual Studio 2010 would be pushed back a few weeks, they stated they would be shipping a Release Candidate (RC) in February.  As of February 8th, the RC is available on the MSDN Subscribers site.  The same downloads will be available publicly on the Microsoft Downloads site starting Wednesday, February 10th.

The overall driving reason for pushing back the launch date was to concentrate on performance.  Brian Harry has a post covering some of the improvements made to performance since Beta 2.  While I’ve only had the RC installed for a very short time, the difference in performance (between Beta 2 and the RC) are noticeable.

If you are planning on installing the RC, here are a few links to help you get going:

  • TFS 2010 Beta2 to RC Upgrade Guide – by Bryan Krieger – a guide for upgrading from Beta 2 to the RC.
  • Visual Studio 2010 Quick Reference Guidance – the Visual Studio 2010 Quick Reference Guidance consists of compact cheat sheets for Team Foundation Server (TFS) 2010 and Visual Studio (VS) 2010, addressing the core problem of teams in the field who are unaware of Visual Studio and Team Foundation Server capabilities or have little time to invest in detailed education.
  • Visual Studio 2010 TFS Upgrade Guide – this guide covers in-place upgrades as well as migration upgrades and details the steps that must be completed for more than a dozen specific scenarios.  For example, enabling branch visualization in upgraded projects, splitting team projects into multiple collections, and much more.
  • Visual Studio Team Foundation Server Branching Guide 2010 – the purpose of this project is to build some insightful and practical guidance around branching and merging with Visual Studio Team Foundation Server 2010.
  • Visual Studio 2010 Team Foundation Server Requirements Management Guidance - the goal of this guidance is to provide formalized Microsoft field experience in the form of recommended procedures and processes, Visual Studio Team System and Team Foundation Server configurations, and skill development references for the Requirements Engineering discipline of your application lifecycle.
  • Visual Studio 2010 and Team Foundation Server 2010 VM Factory - the purpose of this project is to build prescriptive guidance around virtualization of the Visual Studio 2010 and guidance for full automation of the creation of virtual machines using the VM Factory.

Also, check out this post for Visual Studio 2010 pricing.