Within my cake script I'm trying to access the following, to check if it's running on the master branch:
var isMasterBranch = StringComparer.OrdinalIgnoreCase.Equals("master",
BuildSystem.AzurePipelines.Environment.Repository.Branch);
however, when I run dotnet cake
I get the following error
❯ dotnet cake
/Users/x/Repos/y/build.cake(11,17): error CS1061: 'BuildSystem' does not contain a definition for 'AzurePipelines' and no accessible extension method 'AzurePipelines' accepting a first argument of type 'BuildSystem' could be found (are you missing a using directive or an assembly reference?)
The cake version in pinned to 0.38.5 inside the packages.config
:
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Cake" version="0.38.5" />
</packages>
xml
What am I missing?
What version of Cake are you running?
The AzurePipelines
alias was introduced in version 0.38.0. In previous versions you need to use TFBuild
.