How to integrate SP Dispose Check into Visual Studio Solutions


Table of Contents

The SP Dispose check when it is installed is placed by default at

C:\Program Files\Microsoft\SharePoint Dispose Check

Visual Studio Tools menu

You can get this setup so that it is available in all your Visual Studio Projects by following these simple steps.

  • Select 'Tools | External Tools...' from Visual Studio
  • Click New and fill in details as per screen shot:

    NOTE: comman path points to C:\Program Files\Microsoft\SharePoint Dispose Check\SPDisposeCheck.exe.
  • The SP Dispose Check will appear in Tools menu now.

Selecting it will execute the checker and output results in Output window as shown below.

Visual Studio Project Build Targets

You can also edit your .proj file in XML editor and modify the AfterBuild target to include a call to this:

<Target Name="AfterBuild">
<Exec Command='"C:\Program Files\Microsoft\SharePoint Dispose Check\SPDisposeCheck.exe" "$(TargetPath)"' />
</Target>

Visual Studio Build Integration

There is a CodePlex project called spDisposeCheckEx that will integrate with your build process to actually prevent the dll from compiling. This is not the preferred recommendation as you may not want this to run EVERYTIME you do a build. Some developers will use Build command to validate their code is compiling and this will slow down process.

Not tested
This project has not been tested by me but thought it is worth adding here as an option.

Hopefully there won't be too much bad news that it reports!

Labels

dispose dispose Delete
integration integration Delete
Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.



Creative Commons License
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 Unported License.