What docker image can I use for dotnet class library project?

I have create an class Library dot net project (.NET Core 2.0) but I am always receiving an error message on BitBucket Pipeline.

My yml pipeline file were filled as showed below:

 

image: microsoft/dotnet:onbuild

pipelines:
default:
- step:
caches:
- dotnetcore
script: # Modify the commands below to build your repository.
- export PROJECT_NAME=ClassLibrary/ClassLibrary/ClassLibrary
- export TEST_NAME=ClassLibrary/ClassLibrary.Tests/ClassLibrary.Tests
- dotnet restore
- dotnet build $PROJECT_NAME
- dotnet test $TEST_NAME

 

I am receiving this error message on pipeline

 

Couldn't find 'project.json' in 'ClassLibrary/ClassLibrary/ClassLibrary'

1 answer

1 accepted

I changed the value of image parameter on yml file from "microsoft/dotnet:sdk" to "microsoft/dotnet:2.0-sdk" and also changed the default value from "dotnet restore" to dotnet "restore ClassLibrary/ClassLibrary/ClassLibrary.csproj" (Inclusing the full path of project). Now it's working fine.

Below, you can see the final version of yml file:

# This is a sample build configuration for .NET Core.
# Check our guides at https://confluence.atlassian.com/x/5Q4SMw for more examples.
# Only use spaces to indent your .yml configuration.
# -----
# You can specify a custom docker image from Docker Hub as your build environment.
#image: microsoft/dotnet:sdk
#image: microsoft/dotnet:onbuild

image: microsoft/dotnet:2.0-sdk

pipelines:
  default:
    - step:
        caches:
          - dotnetcore
        script: # Modify the commands below to build your repository.
          - export PROJECT_NAME=ClassLibrary/ClassLibrary/ClassLibrary.csproj
          - export TEST_NAME=ClassLibrary/ClassLibrary.Tests/ClassLibrary.Tests.csproj
          - dotnet restore ClassLibrary/ClassLibrary/ClassLibrary.csproj
          - dotnet build $PROJECT_NAME
          - dotnet test $TEST_NAME

Suggest an answer

Log in or Sign up to answer
Atlassian Community Anniversary

Happy Anniversary, Atlassian Community!

This community is celebrating its one-year anniversary and Atlassian co-founder Mike Cannon-Brookes has all the feels.

Read more
Community showcase
Piotr Plewa
Published Dec 27, 2017 in Bitbucket

Recipe: Deploying AWS Lambda functions with Bitbucket Pipelines

Bitbucket Pipelines helps me manage and automate a number of serverless deployments to AWS Lambda and this is how I do it. I'm building Node.js Lambda functions using node-lambda&nbsp...

1,767 views 1 5
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you