Integrate .NET Core, AppVeyor, OpenCover and Codecov

As a developer, I need to take a good rest at night. In my line of work the only way to achieve it is using an integrated workflow pipeline, aka Source Code Management (SCM), Continuous Integration (CI) and Continuous Deployment (CD) with some tools in the middle.

For my new pet project (I will write about it once reach a good maturity level) I use this set of tools/technologies:

OpenCover is the most used framework to generate code coverage reports for .NET framework. It’s open source and well maintain (updated to work with .NET Core).

Codecov is a commercial project from Steve Peak, free for open source projects, and has powerful visualisations from the code coverage report. Can be used with a tonne of frameworks/languages, using OpenCover report format for the .NET framework. Is my preferred platform, since Steve has a great customer service support.

My integrated workflow pipeline is:

Commit to GitHub project

AppVeyor is configured to be triggered when a new commit is done

AppVeyor builds the solution, run the tests and generate the code coverage report

AppVeyor publish the code coverage report to CodeCov

To manage the AppVeyor actions during the build and tests phases I just develop a PowerShell script to run the generate the code coverage report using OpenCover for the projects/classes under test:

The script instructions do the following:

Set as parameters the general configurations, such as locations of the code coverage report, OpenCover and .NET, using the AppVeyor environment variables to set the correct path

Set the parameters to test the WebAPplicationAssemblyStorage project, excluding a dummy class, running the OpenCover console using the parameters

Set the parameters to test the WebApp project, excluding all the bootstrapping code generated by the .NET framework when a web app is created, running the OpenCover console using the parameters

Copy the code coverage report to the AppVeyor artifacts

Set the Python version in the PATH environment variable, installing Python Package Manager and Codecov script, and uploading the code coverage report to Codecov

The Powershell is integrated into appveyor.yml file, integrated into the project solution. The script runs in the ‘test_script’ step.

NOTE: at the time that you are reading this post the script can be different. If that is the case please leave a comment and I will update the Gist. 🙂