Generate code quality report using VSTS task
July 04, 2018 by Anuraj
VSTS PowerShell
While implementing CI for one of the project, I implemented code quality check using Resharper Code Quality Analysis
task. This task can fail the build, but this task will not generate a report. Since this task is internally using Inspectcode.exe
, it will be able to generate the output XML file. In this post, I am writing a simple PowerShell script, which can be used as task, which will generate html report.
So first you need to include the Resharper Code Quality Analysis task in your build pipeline. I am using a Desktop application, so I am building the solution, copying the files to artifacts directory. Then I am running the code quality check.
By default this task won’t create the report xml file. So you need to configure it. You can do it by clicking on the task, select Advanced Options
, and set the Results output file path
property.
Set it to $(Build.ArtifactStagingDirectory)\CodeQualityResults.xml
.
Next you need to add a PowerShell task. Select the Inline
type. And add following code in the Script textbox.
So in this script, I am checking for a XSLT file in the artifacts directory and if not found downloading it from GitHub. Then I am loading the XSLT and transforming it to HTML using XslCompiledTransform
object.
Here is the report is generated via this task.
I have one more task added, which will send an email with report as attachment to the development team. You can do this using email notification tasks or using PowerShell.
Happy Programming :)
Copyright © 2024 Anuraj. Blog content licensed under the Creative Commons CC BY 2.5 | Unless otherwise stated or granted, code samples licensed under the MIT license. This is a personal blog. The opinions expressed here represent my own and not those of my employer. Powered by Jekyll. Hosted with ❤ by GitHub