techblog

TFS 2012 – Configure Automatic SharePoint Build Process – Part2

Dec 11, 2012 by Christoph // 2 Comments

This is the second post of a series of posts about TFS 2012 and build automation for SharePoint 2010.

 

Integrating SPDisposeCheck

SPDisposeCheck is a tool provided by Microsoft to check your Assemblies against undisposed items and therefore helps to provide memory leaks and performance issues.

The tool can be installed on the Developer machine to check for this issues by the developer itself, but can also be integrated into the automatic TFS build process, covered in this section.

Our goal is to integrate it in the new build process template created in the previous post. We want to see results in the build log and on the build summary page. The necessary steps are described in the following sections. This post is mainly based on the great post of Chris O’Brien, but covers TFS 2012 and is a little more detailed.

1. Install SPDisposeCheck

SPDisposeCheck has to be downloaded and installed on the servers acting as build agent. By default, the tool will be installed to the following directory:

C:\Program Files (x86)\Microsoft\SharePoint Dispose Check

Make sure all installations on all agents are using the same directory. You can leave the “Install Visual Studio AddIn” and “Execute SPDisposeCheck after VS Build” checkbox unchecked during installation.

2. Integrate into custom build workflow

Now we have to call SPDisposeCheck during the Build Workflow and report the result to the right channels of the build output.

a. Find the right place to call SPDisposeCheck and add sequence

As mentioned in the previous post, the sequence “Run on agent” is the part where most of the build takes place. We need to call SPDisposeCheck after the assemblies are available and therefore after the compilation. But we need to place it before the gated changes are checked-in, so we can prevent developers from adding source files that are not properly disposed (If we want to. Please keep in mind the false positive SPDisposeCheck creates.).

The following image describes, where I added the sequence containing all the configuration steps within the “Run on agent” sequence. The display name of the sequence is changed to “Run SPDisposeCheck.exe”.

image

b. Create Variables

To store the result of the SPDisposeCheck call, we need to create an integer variable called “SPDisposeCheckResult”. SPDisposeCheck will return the number of undisposed items found.

c. Call SPDisposeCheck

We add an InvokeProcess Activity to the newly created sequence. The properties are modified to the following values:

Arguments String.Format("""{0}""", BuildDetail.DropLocation)
DisplayName Invoke SPDisposeCheck
EnvironmentVariables <empty>
FileName "C:\Program Files (x86)\Microsoft\SharePoint Dispose Check\SPDisposeCheck.exe"
OutputEncoding […]InstalledUICulture.TextInfo.OEMCodePage (default)
Result SPDisposeCheckResult (the variable declared in the previous step)

d. Report Results to Log and Summary

To display the results within the build log file and the build summary page, we add the following items:

image

First we add an IF Activity and check if any items are returned by SPDisposeCheck (SPDisposeCheckResult > 0).

A sequence is added to the "THEN” area. We put a WriteBuildWarning Activity in there that has the following output message:

“String.Format("SPDisposeCheck found {0} issues. Please review the issues.", SPDisposeCheckResult)”

Also a WriteCustomSummaryInformation Activity is added with the following settings:

Message String.Format("SPDisposeCheckResult found {0} issues. Please check Log-File for details.", SPDisposeCheckResult)
SectionDisplayName "SharePoint Quality Checks"
SectionKey "SharePointQualityChecks"
SectionPriority 0

The “ELSE” area contains a WriteCustomSummaryInformation Activity similar to the one in the "THEN” area, but with a positive message.

e.  Update Build Definition & Execute Build

To make the new Workflow available, you have to save and check-in the changes we made. Afterwards, we can start a test build to see if the changes take effect. Therefore, you can create a small test project containing some undisposed items.

Afterwards, we see the execution of the SPDisposeCheck in the Activity Log during the build.

image

The details are reported to the build log file.

image

And you can see the status in the Build Summary as an overview:

image

2 Comments to “TFS 2012 – Configure Automatic SharePoint Build Process – Part2”

Leave a Reply

  • (will not be published)

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

Copyright © 2012 techblog All Rights Reserved.

The posts on this weblog are provided “AS IS” with no warranties, and confer no rights. The opinions expressed herein are personal and do not represent those of my employer.

Designed & Developed by ThemeElephant