Expand Minimize

How to: Run SPCAF in a TFS 2015/VSTS TeamBuild

This functionality is only available in SPCAF Quality Gate. Feature Comparison
Note: At the moment in TFS 2017 you are only able to upload using the tfx command line tool located here.

SharePoint code analysis can also be executed during a TFS Team Build. This helps to ensure the correctness of the SharePoint code. During the Team Build, all found errors and warnings are listed in the build result. Additionally, the SPCAF reports can be generated and saved to the output directory.

The following described integration of SPCAF is possible for the following products:

  • Team Foundation Server 2015
  • Visual Studio Team Services (VSTS)

To integrate SPCAF into the build process the following steps needs to be performed:

  1. Upload the SPCAF Build Task for TFS 2015 to TFS Server or VSTS
  2. Add a SPCAF build step to your build definition
  3. Configure the build step and run it

Note: There is no installation of SPCAF on the TFS build servers necessary.

1. Uploading the SPCAF Build Task to TFS 2015 or VSTS

The SPCAF Build Task needs to be uploaded to your TFS 2015 or VSTS (via HTTP). To simplify this step SPCAF provides a separate application which uploads the build task automatically.

  1. Download a preconfigured package of "SPCAF Quality Gate for TFS 2015 and VSTS" from our Downloads page. (https://www.spcaf.com/downloads/)
  2. Extract the downloaded package to a temporary directory, e.g. c:\temp\SPCAFTemp
  3. Run the SPCAF.TaskUploader.exe application
  4. Enter the URL and the credentials of your TFS or VSTS server
  5. Click "Start Upload".

The following screenshots shows the result after successful upload.

Add a SPCAF build step to your build definition

After successful upload the SPCAF build task is ready to be integrated into a build definition.

  1. Create a new build definition or open an existing one
  2. Click "Add..." to add an additional build step to the build definition
  3. Select category "Build", select in this category the SPCAF build task and click "Add"
  4. Select the newly added SPCAF task and configure the build task to your needs
  5. Save the build definition

Configuration of build step

The following parameters can be configured for the build step.

Standard Settings

ArgumentDescriptionSample Value
Input directoryRequired String. Relative or absolute path to the folder with the analyzable files (e.g. to the drop location).artifacts\drop\bin
Output directoryOptional String. Relative or absolute path to the folder where the result reports should be written to. Relative path is appended to the drop location.artifacts\drop\SPCAFReports
SPCAF License KeyOptional String. Relative or absolute path to the license key file (.lic). If empty only summary reports are created. Relative path is appended to the sources directory.\SPCAF\License.lic
SPCAF Settings FileOptional String. Relative or absolute path in source directory to the settings file. Relative path is appended to the sources directory..RS02_MinimumRecommendedRules


ArgumentDescriptionSample Value
HTMLIf checked a HTML report is created as result of the analysis.
DOCXIf checked a MS Word (.docx) report is created as result of the analysis.
PDFIf checked a Adobe PDF report is created as result of the analysis.
CSVIf checked a CSV report is created as result of the analysis (can be opened in MS Excel).
XMLIf checked a XML report is created as result of the analysis.
Dependency DiagramIf checked a Visual Studio DGML Diagram is created as result of the analysis.

Advanced Options

ArgumentDescriptionSample Value
Log FileRelative or absolute path in source directory to the log file.//fileshare/spcaf.log
Output filenameName of the output files. The name is used as a prefix for all generated reports.spcafresult.html
VerbosityLevel for verbosity to limit the detail level for log messages. Valid values are: quiet, minimal, normal, Default.normal
Temp FolderRelative or absolute path in source directory to the temp folder.//fileshare/tmp
Skip Project CreationIf TRUE no project (.spcaf) file is created as output of the analysis.
TimeoutOptional seconds after the analysis should be cancelled automatically.60000
FiltersOptional list of extensions to filter the input files, e.g. '*.wsp;*.app'.*.wsp;*.app;*.dll
RecurseIf TRUE input directory are recursively scanned for analyzable files, if FALSE only the given root will be scanned.
Treat Errors as WarningsIf TRUE identified errors are reported as warnings.
Custom Rules FolderOptional path to custom SPCAF rule assemblies.//fileshare/customrules

Run a build and verify analysis results

After successful configuration you can run a build and check the correct integration of SPCAF into the build process.

If SPCAF can find errors or warning they are displayed in the output of the build, see sample below:

To download the SPCAF analysis result reports go to section "Artifacts" in the build result. From there you can download a ZIP file which contains the created reports.

After download you have access to all generated reports:

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. 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.