Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

how to set up bitbucket pipeline to build .Net core 5.0 project

Deleted user November 14, 2021

Exploring bitbucket pipeline to create a CI/CD for a .net 5.0 microservice project. Please find the .yml file below

 

pipelines:
branches:
POR-2191:
- step:
name: Build MicroService
caches:
- dotnetcore
image: mcr.microsoft.com/dotnet/sdk:5.0
script:
- export PROJECT_NAME=MyProjectName
- dotnet restore
- dotnet build $PROJECT_NAME

 But I am seeing this error when the pipeline runs,


Error:

dotnet build $PROJECT_NAME
+ dotnet build $PROJECT_NAME
Microsoft (R) Build Engine version 16.11.2+f32259642 for .NET
Copyright (C) Microsoft Corporation. All rights reserved.
Determining projects to restore...
Restored /tmp/10vu21df.v2w/WorkerExtensions.csproj (in 1.42 sec).
WorkerExtensions -> /tmp/10vu21df.v2w/buildout/Microsoft.Azure.Functions.Worker.Extensions.dll
/root/.nuget/packages/microsoft.net.sdk.functions/3.0.11/build/Microsoft.NET.Sdk.Functions.Build.targets(32,5): error : It was not possible to find any compatible framework version [/tmp/10vu21df.v2w/WorkerExtensions.csproj]
/root/.nuget/packages/microsoft.net.sdk.functions/3.0.11/build/Microsoft.NET.Sdk.Functions.Build.targets(32,5): error : The framework 'Microsoft.NETCore.App', version '3.1.0' was not found. [/tmp/10vu21df.v2w/WorkerExtensions.csproj]
/root/.nuget/packages/microsoft.net.sdk.functions/3.0.11/build/Microsoft.NET.Sdk.Functions.Build.targets(32,5): error : - The following frameworks were found: [/tmp/10vu21df.v2w/WorkerExtensions.csproj]
/root/.nuget/packages/microsoft.net.sdk.functions/3.0.11/build/Microsoft.NET.Sdk.Functions.Build.targets(32,5): error : 5.0.12 at [/usr/share/dotnet/shared/Microsoft.NETCore.App] [/tmp/10vu21df.v2w/WorkerExtensions.csproj]
/root/.nuget/packages/microsoft.net.sdk.functions/3.0.11/build/Microsoft.NET.Sdk.Functions.Build.targets(32,5): error : [/tmp/10vu21df.v2w/WorkerExtensions.csproj]
/root/.nuget/packages/microsoft.net.sdk.functions/3.0.11/build/Microsoft.NET.Sdk.Functions.Build.targets(32,5): error : You can resolve the problem by installing the specified framework and/or SDK. [/tmp/10vu21df.v2w/WorkerExtensions.csproj]
/root/.nuget/packages/microsoft.net.sdk.functions/3.0.11/build/Microsoft.NET.Sdk.Functions.Build.targets(32,5): error : [/tmp/10vu21df.v2w/WorkerExtensions.csproj]
/root/.nuget/packages/microsoft.net.sdk.functions/3.0.11/build/Microsoft.NET.Sdk.Functions.Build.targets(32,5): error : The specified framework can be found at: [/tmp/10vu21df.v2w/WorkerExtensions.csproj]
/root/.nuget/packages/microsoft.net.sdk.functions/3.0.11/build/Microsoft.NET.Sdk.Functions.Build.targets(32,5): error : - https://aka.ms/dotnet-core-applaunch?framework=Microsoft.NETCore.App&framework_version=3.1.0&arch=x64&rid=debian.10-x64 [/tmp/10vu21df.v2w/WorkerExtensions.csproj]
/root/.nuget/packages/microsoft.net.sdk.functions/3.0.11/build/Microsoft.NET.Sdk.Functions.Build.targets(32,5): error : [/tmp/10vu21df.v2w/WorkerExtensions.csproj]
/root/.nuget/packages/microsoft.net.sdk.functions/3.0.11/build/Microsoft.NET.Sdk.Functions.Build.targets(32,5): error : Metadata generation failed. [/tmp/10vu21df.v2w/WorkerExtensions.csproj]
Build FAILED.
Looks like it also needs .net 3.1.0. But not sure how to do it. Tried by including Services like below but no luck.
definitions:
services:
sdk:
image: mcr.microsoft.com/dotnet/core/sdk:3.1

1 answer

1 vote
Andy Jiang
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
November 24, 2022

Hi @[deleted] ,

We also encountered this issue, and the current work around the adapted is to use dotnet-install.sh script to install another version of dotnet sdk in the script.

Before you run dotnet restore and build, run below script to download dotnet-install.sh and use it to download and install sdk version 3.1.

- curl -sSL https://dot.net/v1/dotnet-install.sh | bash /dev/stdin -Channel 3.1 -Runtime dotnet -InstallDir /usr/share/dotnet

 Hope this helps.

Joe
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
March 21, 2024

This helped me. Thanks, @Andy Jiang !

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events