This article will guide you through how to run SPCAF in TFS 2015/VSTS.
Note: This functionality is only available in SPCAF Build License.
Note: At the moment in TFS 2017 you are only able to upload using the tfx command line tool. More details are 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:
- Upload the SPCAF Build Task for TFS 2015 to TFS Server or VSTS.
- Add a SPCAF build step to your build definition.
- Configure the build step and run it.
Note: There is no installation of SPCAF on the TFS build servers necessary.
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 that uploads the build task automatically.
- Download a preconfigured package of "SPCAF Quality Gate for TFS 2015 and VSTS" from our Download Page.
- Extract the downloaded package to a temporary directory, e.g. c:\temp\SPCAFTemp.
- Run the SPCAF.TaskUploader.exe application.
- Enter the URL and the credentials of your TFS or VSTS server.
If using VSTS server you must use Alternate authentication credentials set within your VSTS profile.
- Click "Start Upload".
The following screenshots show the result after a successful upload.
Add an SPCAF build step to your build definition
After a successful upload, the SPCAF build task is ready to be integrated into a build definition.
- Create a new build definition or open an existing one.
- Click "Add..." to add an additional build step to the build definition.
- Select the category "Build", select in this category the SPCAF build task and click "Add".
- Select the newly added SPCAF task and configure the build task to your needs.
- Save the build definition.
Configuration of build step
The following parameters can be configured for the build step.
|Input directory||Required String. A relative or absolute path to the folder with the analyzable files (e.g. to the drop location).||artifacts\drop\bin|
|Output directory||Optional String. Relative or absolute path to the folder where the result reports should be written to. A relative path is appended to the drop location.||artifacts\drop\SPCAFReports|
|SPCAF License Key||Optional String. Relative or absolute path to the license key file (.lic). If empty only summary reports are created. A relative path is appended to the sources directory.||\SPCAF\License.lic|
|SPCAF Settings File||Optional String. Relative or absolute path to the source directory to the settings file. A relative path is appended to the sources directory.||RS02_MinimumRecommended Rules|
|HTML||If checked an HTML report is created as a result of the analysis.|
|DOCX||If checked an MSWord (.docx) report is created as a result of the analysis.|
|If checked an Adobe PDF report is created as a result of the analysis.|
|CSV||If checked a CSV report is created as a result of the analysis (can be opened in MS Excel).|
|XML||If checked an XML report is created as a result of the analysis.|
|Dependency Diagram||If checked a Visual Studio DGML Diagram is created as a result of the analysis.|
|Log File||Relative or absolute path to the source directory to the log file.||//fileshare/spcaf.log|
|Output filename||Name of the output files. The name is used as a prefix for all generated reports.||spcafresult.html|
|Verbosity||Level for verbosity to limit the detail level for log messages. Valid values are: quiet|minimal|normal|default||normal|
|Temp Folder||Relative or absolute path to the source directory to the temp folder.||//fileshare/tmp|
|Skip Project Creation||If TRUE no project (.spcaf) file is created as an output of the analysis.|
|Timeout||Optional seconds after the analysis should be canceled automatically.||60000|
|Filters||Optional list of extensions to filter the input files. e.g. .wsp, .app||*.wsp; *.app; *.dll|
If TRUE input directory is recursively scanned for analyzable files.
If FALSE only the given root will be scanned.
|Treat Errors as Warnings||If TRUE identified errors are reported as warnings.|
|Custom Rules||Optional path to custom SPCAF rule assemblies.||//fileshare/customrules|
Run a build and verify analysis results
After a 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 the 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 that contains the created reports.
After download you have access to all generated reports:
Pre-Production | TFS | 2015 | VSTS | 2010/2013 | TeamBuild | Run