Psake is a PowerShell based process automation tool that can be used to automate a large variety of tasks. In this series, we explore the different ways that Psake can be used to streamline your development process. We’ll see how to use it to specify version numberes, run builds, execute tests, report on test coverage, and more.

An Introduction to Psake

29 Jul 2017 psake powershell

There are a lot of benefits to the automation of tedious and/or error prone activities. With suitable preparation, we can dramatically speed things up while reducing the rate of errors considerably. In some cases, we can eliminate errors completely. For all this, it can sometimes be difficult working out where to start.


Finding MSBuild

5 Aug 2017 psake powershell

One of the goals of build automation is to create a robust and reliable process that can be depended upon. To achieve this, our build script needs to be smart, transparent and maintainable.


Readable output from a build

12 Aug 2017 psake powershell

It’s important to make it easy to understand what our build script has done. A failing build is always a troublesome distraction at an inconvenient time, so we need to make it as easy as possible to identify the problem and move on.


Unit Testing

19 Aug 2017 psake powershell

A push button build script that does exactly one thing isn’t that useful - we could achieve as much by building from within Visual Studio itself. The benefits of build automation begin to accrue when we start orchestrating multiple steps. Let’s extend the script to automatically run all our unit tests.


Controlling build types

26 Aug 2017 psake powershell

While it’s not strictly required by this project, let’s look at what would be required to set up different build targets for different purposes. Currently our Compile.Assembly task just compiles whatever defaults are baked into the project. Let’s change that so we can specify whether we want Release or Debug builds.


Launch Scripts

2 Sep 2017 psake powershell

To simplify the use of our build scripts, and to make it easier for someone new to the project to work out how things work, we’ll create some convenience PowerShell scripts to launch the build. We’ll create three scripts, for three different purposes: one for moment to moment use by a local developer; one to do a release build when the project is ready for distribution; and one for our continuous integration server.


Versioning

9 Sep 2017 psake powershell

Version numbering is an odd detail - one we can (and should) easily ignore at the start of a project. There comes a point, however, where we find that version numbering is vitally useful. At that point, we usually discover that we should have started versioning things about six months ago … and now we have a mess to clean up.


Semantic versioning

16 Sep 2017 psake powershell

Perhaps the most significant problem with the simplistic versioning system we put into place last time is that we can get the same version number generated on different branches. Fortunately, semantic versioning gives us room to fix this by adding a descriptive suffix to the build number.


NuGet packaging

23 Sep 2017 psake powershell

While NuGet provides all the power needed to explicitly control every aspect of a package (something the exacting control freak in me really appreciates), a simple project like this doesn’t need anything more than the standard conventions.


Test Coverage with Opencover

30 Sep 2017 psake powershell

Once you have a reasonable suite of unit tests, you might start to wonder how much of your code is properly tested. Measuring coverage gives one perspective, and it’s one we can easily add to our builds.


Test Coverage Reporting

7 Oct 2017 psake powershell

Building on our previous post, we can take the coverage information generated by OpenCover and generate a report that shows us where our coverage is lacking.


.NET Core Builds

21 Oct 2017 psake powershell

Part way through writing this series, I decided to convert the Niche.CommandLine project to .NET Core, which of course required a bunch of changes to the Psake build script. Let’s look at what was required.


NuGet and .NET Core

28 Oct 2017 psake powershell

After my previous post on upgrading my project to compile with .NET Core, I found some unexpected issues compiling my NuGet package.


The day my build broke

4 Nov 2017 psake powershell

Recently, one of my build scripts failed with an odd error, claiming that the application wasn’t recognized. Given that the script had been working fine the previous day, this error was rather confusing.


Tracking time

11 Nov 2017 psake powershell

For diagnostic purposes, it can often be useful to know when specific build tasks started and how long they took to execute. This information can help you spot anomalies and resolve odd issues.


Test Coverage History

18 Nov 2017 psake powershell

On my previous post on code coverage, someone asked if the coverage report could highlight areas where coverage decreased. It turns out that ReportGenerator can do this, but there’s room for improvement.


Bootstrapping a Psake build

1 Sep 2018 psake powershell

The PowerShell based tool psake is a great way to orchestrate a build. It can also be used for many other kinds of orchestration. One of the trickiest parts is kicking off the process in the first place.


Related posts

Checklists, Automation and Consistency  19 Jul 2015