I had an interesting problem updating my GherkinSyntax project when my Azure DevOps Pipeline builds started failing with error NU1604. Local builds worked fine, only the cloud builds were failing.

The error was this:

The nuget command failed with exit code(1) and error
(NU1604: Project dependency Microsoft.NETCore.App does not contain an inclusive lower bound.
Include a lower bound in the dependency version to ensure consistent restore results.
Errors in d:\a\1\s\tests\Niche.GherkinSyntax.Tests\Niche.GherkinSyntax.Tests.csproj

Usefully, the error message contains a unique identifier I could use to search for possible solutions: NU1604

Unfortunately, it took me quite some time to find an answer, because many of the folks complaining about this error had either never found an answer, or they’d neglected to share their answer when they found it.

Pro Tip: If you publicly ask for help with your problem, follow up and share the answer when you find it. Those who live in the future and encounter the same problem will thank you.

It turned out that my problem was due to an older version of nuget.exe.

By default (at the time of writing, at least), Azure DevOps uses version 4.3 of the NuGet tools - and that version (and, presumably, earlier versions) have a problem with projects using .NET Core 2.2 or later.

The fix is to request a later version of the NuGet tools. I changed my azure-pipelines.yml file to include this step at the start:

- task: NuGetToolInstaller@0
  inputs:
    versionSpec: '4.x'

The 4.x specified the latest available version of Nuget 4.x … which means I’ll need to revisit this if one of the referenced packages acquires a dependency on NuGet 5.x or later.

For now, however, my builds work properly and that’s enough for today.

Comments

blog comments powered by Disqus