Fixing 'Could not inject value for GitVersion' in Azure Pipelines

If you are using GitVersion with NUKE and you are trying to get the pipeline working, but are running into the build failing with Could not inject value for GitVersion.

I will assume you are using a YAML pipeline (and in my case I was pulling the sources from GitHub), try this.

First open the pipeline that is experiencing issues and go select ‘Edit’:

Screenshot of Azure Pipelines overview.

Select the additional settings that are collapsed and go to ‘Triggers’:

Expanded additional settings with Triggers highlighted

Once there, select YAML and the repository and make sure that ‘Shallow fetch’ is disabled.

Screenshot showing Shallow Fetch unchecked

This solved the issue for me and GitVersion started working as expected.