Expand Minimize

How to: Run SPCAF with MSbuild

MSBuild integration in a TeamBuild (e.g. on Team Foundation Server) is only available in SPCAF Server. The client licenses can use MSBuild vor the local build in Visual Studio.

Configure Project File

SPCAF can run the code analysis also during a local build. For this SPCAF comes with a custom MSBuild task and a .targets file.

The MSBuild files are installed by default into "C:\Program Files (x86)\MSBuild\SPCAF". You can reference this path with '$(MSBuildExtensionsPath)\SPCAF\'.

Note: The MSBuild files are installed by default. Do not disable them during installation.

To integrate the analysis into your local build add the following line to your SharePoint project file (.csproj), right after the existing import statements.

  Condition="'$(BuildingInsideVisualStudio)'=='true' AND Exists('$(MSBuildExtensionsPath)\SPCAF\SPCop.targets')"
  Project="$(MSBuildExtensionsPath)\SPCAF\SPCop.targets" />

Build the project and the analysis will show the errors and warnings in the error list of Visual Studio.

Enable or Disable analysis

You can enable or disable the analysis, e.g. depending on building 'Debug' or 'Release' configuration as follows:


Change Ruleset for local build

Define the following parameter in the .csproj file to change the ruleset for the analysis:
Disclaimer: The views and opinions expressed in this documentation and in SPCAF do not necessarily reflect the opinions and recommendations of Microsoft or any member of Microsoft. SPCAF and RENCORE are registered trademarks of RENCORE AB. All other trademarks, service marks, collective marks, copyrights, registered names, and marks used or cited by this documentation are the property of their respective owners.