Tuesday, October 15, 2019

.NETcore on Bitbucket pipeline error: A compatible SDK version for global.json version not found

Problem

We successfully moved to continuous integration earlier this year and are working on setting up our development with a continuous deployment. To run our tests on every pull request, we wanted a pipeline step that would ensure all our tests passed. The project is on .NET core v2.2.

At first, I tried the default configuration using microsoft/dotnet:sdk but ran into the following issue:

A compatible SDK version for global.json version: [2.2.101] from [/opt/atlassian/pipelines/agent/build/Project/global.json] was not found
Did you mean to run dotnet SDK commands? Please install dotnet SDK from:
  https://go.microsoft.com/fwlink/?LinkID=798306&clcid=0x409

After researching this a bit, it finally dawned on us that there was an incompatibility between our global.json defined version and the SDK version available in the Docker image.


Solution

It turned out we needed to ensure that our global.json version had to match the SDK version available. In our case, we determined we no longer needed the global.json file and removed it.


For reference, here is what our pipeline configuration looked like:

bitbucket-pipelines.yml

pipelines:
  default:
    - step:
        name: Build and Run Back-End Unit Tests
        image: mcr.microsoft.com/dotnet/core/sdk:2.2
        caches:
          - dotnetcore
        script:
          - cd Project/
          - dotnet restore
          - dotnet build ProjectService --no-restore
          - dotnet test ProjectService_Tests --no-build --no-restore

No comments: