Category Archives: 18401

Notifying users when a particular work item changes in TFS

The Goal

In TFS you can set up Project Alerts that alert users when work items change. But sometimes you would like to be able to add a list of people to be notified when a particular work item changes.

The Solution

You can achieve this by using a server-side plug-in.

Here’s a step-by-step guide:

  1. Enable SMTP settings for your TFS in TFS Admin Console (if not already done)
  2. Add a custom field to your work item types:
    Type = “string”, Reference Name = “TFS.CcNotificationReceivers”
    image
    … and display it on the Work Item form:
    image
  3. Install server-side plug-in:
    Get TFS.WorkItemTracking.CcNotifications.dll from here (for TFS 2013 only!) and copy it to the “PlugIns” folder, located at: %ProgramFiles%\Microsoft Team Foundation Server 12.0\Application Tier\Web Services\bin\Plugins
    (to uninstall, simply delete the .DLL again)
  4. Done. When you enter user names (or e-mail addresses) into the new field (separate multiple values with commas or semicolons), those users will be notified of any changes that happen to that particular work item.

image

Note: Server-side plug-ins work on TFS on-premises only (not with Visual Studio Online).

Enjoy!

–Neno

Turning off policy overrides in TFS

The Goal

Check-In policies have been around since the first version, TFS 2005, to help a team define a list of steps they want to perform prior the checking in. If a policy is not met, it alerts the user.

When policies fail, there is an option to “override” the warning(s) and continue with the check-in (the policy warnings will still be stored as part of the changeset).

Figure 6.6 CheckIn Policy Violations

While it’s easy to set up an alert to get notified when this happens, or query the TFS Warehouse to get a list of all overrides, there’s no built-in way to turn off overrides entirely.

The Solution

A server-side plug-in that intercepts all check-ins and rejects the changeset if it is a policy override. After activating the plug-in (which is simply a drag & drop of the plug-in .DLL into a specific folder on the TFS Application Tier), this is what happens if users try to override:

No Policy Overrides

How to set it up

  • To install, copy TFS.VersionControl.NoPolicyOverrides.dll to the “PlugIns” folder, located at: %ProgramFiles%\Microsoft Team Foundation Server 12.0\Application Tier\Web Services\bin\Plugins
  • Download the .ZIP package with all event-handlers here (for TFS 2013 only!).
  • To uninstall, just remove the .DLL from the “PlugIns” folder.

A word of warning

Disclaimer:
Server-side event handlers must be very well written. As they run inside of the TFS process itself, they can crash TFS, significantly degrade performance or change the behavior of built-in operations (e.g. a badly written plug-in could cause new team project creation to fail).

Note: Server-side plug-ins work on TFS on-premises only (not with Visual Studio Online).

Enjoy!

–Neno

Extending TFS’ default behavior using server-side plug-ins

In TFS 2005, Check-In Policies helped to ensure certain rules prior to check-in. However, check-in policies are executed locally and you must ensure they are available for the client (in the appropriate version) and installed.

In TFS 2010, Gated Check-Ins were introduced, which allowed validations such as the compilation, unit test execution and more (basically whatever the build script specified) to be run on the server-side and reject the check-in if they failed.

Also with TFS 2010, Microsoft introduced server-side plug-ins, which can handle TFS events and either react to them, or – in some cases – even cancel operations. Technically those plug-ins are implementing the ISubscriber interface (see this blog post how to write and debug them).

A word of warning:

Disclaimer:
Server-side event handlers must be very well written. As they run inside of the TFS process itself, they can crash TFS, significantly degrade performance or change the behavior of built-in operations (e.g. a badly written plug-in could cause new team project creation to fail).

Here’s an example:

Instead of using a check-in policy to enforce that changesets must have comments, a server-side plug-in could be used instead. This would guarantee that our rules are enforced, regardless of the client accessing TFS and if the appropriate check-in policy is available and installed for that client or not.

The server-side plug-in is installed by just copying a single .DLL to a “PlugIn” folder on the TFS Application Tier (or all Application Tier if you have more than one).

The following screenshots show how the message looks like that users will see that try to check-in without a comment.

In Visual Studio:

image
In Windows Explorer (via TFS Shell Extension from TFS Power Tools):

image
In Eclipse:

image

How to set it up

  • To install, copy TFS.VersionControl.RequireChangesetComments.dll to the “PlugIns” folder, located at: %ProgramFiles%\Microsoft Team Foundation Server 12.0\Application Tier\Web Services\bin\Plugins
  • Download the .ZIP package with all event-handlers here (for TFS 2013 only!).
  • To uninstall, just remove the .DLL from the “PlugIns” folder.

Note: Server-side plug-ins work on TFS on-premises only (not with Visual Studio Online).

Enjoy!

–Neno