sexta-feira, 20 de fevereiro de 2009

SPDisposeCheck Tool How To Use in "Post-Build"

SPDisposeCheck is a new tool to check your assemblies or exe that you use in SharePoint. but you can increase your potencial using it on "post-build events" in Visual Studio.

How:




Before install the tool, go to

"C:\Program Files\Microsoft\SharePoint Dispose Check\", you can check that this folder contains the file "SPDisposeCheck.exe.
To run spdisposecheck tool on "post built events" you must check the next steps:

- First add "SPDisposeCheck.exe" to "environment variables" or put the "SPDisposeCheck.exe" in System32 Folder.
Now your enviroment has ready to use SPDisposeCheck

The SPDisposeCheck tool only check assemblies or exe files, you must verify your output type.

In your project go to "Built Events" and add the following command line:

___________________________________________________
SPDisposeCheck "$(TargetPath)" -debug > c:\logs\CheckDisposeLog.txt
___________________________________________________


"$(TargetPath)" -> "c:\...\...\...\...\...\project\bin\(debug/release)\projectname.exe"
or
"$(TargetPath)" -> "c:\...\...\...\...\...\project\bin\(debug/release)\projectname.dll"

"> c:\logs\CheckDisposeLog.txt" -> location of your report

Its more simple for you use post built macros.









Now, built the solution and test it:
My code with the correct dispose:








Check log file











My Code without web dispose:








Check the log file:













hope this helps,

Sem comentários: