Sonarcloud with bitbucket+asp.net 4.5 + msbuild

We currently have a asp.net web application repository in bitbucket. I am trying to create a pipeline which will connect to sonarcloud and runs analysis.

Is this set up possible?

image: microsoft/dotnet:sdk

pipelines:
  branches:
    "{master,bitbucket-pipeline}":
      - step:
          name: Running SonarCloud Analysis for master branch
          services:
            - docker
          script:
            - apt-get update
            - apt-get install --yes --force-yes openjdk-8-jre            
            - dotnet tool install --global dotnet-sonarscanner
            - export PATH="$PATH:/root/.dotnet/tools"             
            - dotnet sonarscanner begin /k:"****" /d:"sonar.login=${SONAR_TOKEN}" /v:"${BITBUCKET_COMMIT}" /d:"sonar.host.url=https://sonarcloud.io"
            - dotnet msbuild Src/****.csporj
            - dotnet sonarscanner end /d:"sonar.login=${SONAR_TOKEN}"
  pull-requests:
      '**': #this runs as default for any branch not elsewhere defined in this script
      - step:
          name: Running SonarCloud Analysis For Pull Requests
          services:
            - docker
          script:
            - apt-get update
            - apt-get install --yes --force-yes openjdk-8-jre
            - export PATH="$PATH:/root/.dotnet/tools/dotnet-sonarscanner"
            - dotnet tool install --global dotnet-sonarscanner
            - dotnet sonarscanner begin /k:"****" /d:"sonar.login=${SONAR_TOKEN}" /v:"${BITBUCKET_COMMIT}" /d:"sonar.host.url=https://sonarcloud.io"
            - dotnet msbuild Src/****.sln
            - dotnet sonarscanner end /d:"sonar.login=${SONAR_TOKEN}"
definitions:
  services:
    docker:
      memory: 3072 # increase memory for docker-in-docker from 1GB to 3GB

I ran into this error:
/usr/share/dotnet/sdk/2.1.804/Microsoft.Common.CurrentVersion.targets(1175,5): error MSB3644: The reference assemblies for .NETFramework,Version=v4.5 were not found. To resolve this, install the Developer Pack (SDK/Targeting Pack) for this framework version or retarget your application. You can download .NET Framework Developer Packs at https://aka.ms/msbuild/developerpacks [/Src/***.csproj]

I believe it is not possible to run this because linux doesn’t support .net framework and only supports core.
Are there any other alternatives to this?

Hi @sriharsham,

Have you tested with mono ?

Otherwise yes the .net framework is not buildable on linux with the dotnet sdk image. You can however build your bitbucket code on Azure DevOps :wink:

HTH,
Mickaël