This article guides you through how to run SPCAF in Azure DevOps
Note: This functionality is only available in SPCAF Build License.
SharePoint code analysis can also be executed during an Azure DevOps Build. This helps to ensure the correctness of the SharePoint code. During the 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.
To integrate SPCAF into the build process the following steps needs to be performed:
- Install the SPCAF Build Task. Either by:
- Add the SPCAF build step to your build definition.
- Configure the build step.
- Run the pipeline.
Uploading the Build Task
The SPCAF Build Task needs to be uploaded to your Azure DevOps (via HTTP). To simplify this step SPCAF provides a separate application that uploads the build task automatically.
- Download a preconfigured package of "Integrations for Build and Deployment process" from our Download Page.
- Extract the Rencore.Code.SPCAF.Build.AzureDevops.zip to a temporary directory, (e.g. c:\temp\SPCAFTemp).
- Run the Rencore.SPCAF.TFS2015.TaskUploader.exe application.
- Enter the URL and the credentials of your Azure DevOps Environment.
- Click "Start Upload".
The following screenshots show the result after a successful upload.
Install from the Marketplace.
The SPCAF Build Task needs to be installed to your Azure DevOpsOnce from the Marketplace.
- Once logged into your environment click on the Marketplace icon and choose "Browse marketplace".
- In the search bar type "SPCAF" and click [Enter].
- Click on "SPCAF Customization Analysis for Microsoft SharePoint and Office 365".
- Click "Get Free" on the new screen that loads up.
- Select the Azure DevOps organization you wish to install SPCAF to and then click "Install".
- Click "Proceed to Organization".
Add the SPCAF build step to your build definition
After a successful install, the SPCAF build task is ready to be integrated into a build definition.
- Create a new build definition or open an existing one.
- Edit the Pipeline.
- Click "+" to add an additional build step to the build definition.
- In the search enter "SPCAF", select in this category the SPCAF build task, and click "Add".
Optional, Now that you have added SPCAF. We advise that you add another task "Copy Files". Configure this task as follows:
Display name: Copy File to: Artifacts Drop
Source Folder: Set to the Binaries folder from your MSbuild Task (e.g SharePointProject1\bin\$(buildConfiguration)).
Oufolder: Set this to the Azure DevOps Artifact Staging Directory (i.e. $(build.ArtifactStagingDirectory))
Move this step to be after the MSBuild Task and before the SPCAF Task.
Configure the build step
In order for SPCAF to analyze the project, you will need to configure the task.
- Select the newly added SPCAF task and configure the build task to your needs.
- Here you will need to set the following details as a minimum:
Argument Description Sample Value 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
It is also possible to add the configure the additional advanced setting to SPCAF.
Argument Description 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.
Argument Description Sample Value 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 Recurse
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
- Reorder the Tasks so that you have the "Build Solution" then "Copy Files" then "SPCAF" and finally the "Publishing build artifacts".
- Save the build definition.
Run the pipeline.
After a successful configuration, you can run a build and check the correct integration of SPCAF into the build process.
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.