Check for Warnings/Errors Check-in Policy

Home / TFS / Check-in Policies / Check for Warnings/Errors Check-in Policy

A few days ago a fellow co-worker asked if I knew of a TFS check-in policy that checks for Visual Studio compilation errors and/or warnings.  I wasn’t aware of such a check-in policy (although it may exist out there somewhere) so I decided to go ahead and create it (who doesn’t love a challenge?!).

When active, this check-in policy will evaluate the current Visual Studio solution to determine if any build warnings and/or errors are present.  If so, the check-in policy will fail and will prevent the code from being checked in (this can, of course, be overridden).

To enable this check-in policy:

  1. Download and install the CheckForWarningsPolicy from here.
  2. Right-click the desired team project within the Team Explorer client and select the “Team Project Settings—>Source Control” menu item.
  3. Click the “Check-in Policy” tab and click “Add”.
  4. Select the “Check for Compilation Warnings and Errors Policy” and click OK.
  5. Click the “Edit” button and select whether you’d like to check for warnings, errors, or both and click OK:

Check for Compilation Warnings and Errors Policy Editor

Once enabled, you will see a list of policy failures in the Policy Warnings tab of the Pending Changes pane:

Pending Changes - Policy Warnings

If you hover over the policy failure, the ToolTip will display the remainder of the filename along with the line and column number and project name of the failure.

UPDATE: You can now double-click on the policy failure to navigate directly to the location within code where the failure occurred (assuming the location information is available).

You can download the CheckForWarningsPolicy from here.

ContactUs.com