Help for using sonar cloud with bitbucket with C #

We have a project in C # that is working on Visual Studio 2019 and Microsoft .NET Framework 4.5, the plan is to integrate Bitbucket with Sonarcloud, we have a yml file with the Sonarcloud configuration running, when executing it always fails when executing the dotnet command build ExLide.sln.

This is the configuration we have in the project:

Visual studio information.

  • Visual Studio 2019

  • Microsoft .NET Framework 4.5

These are the installed packages:

  • MSBuild.Microsoft.VisualStudio.Tools.Office.targets.15.0.1

  • Newtonsoft.Json.12.0.3

These are the extensions:

  • SonarLint.VSIX-4.25.0.20544-2019

  • vsta_setup

Sonarcloud information.

  • Sonarclud configuration
    • Sonarcloud organization name: exlide
    • Sonarcloud Key: exlide-main
    • sonarcloud project name: ms-vsto-extension

Script bitbucket-pipelines.yml

image: microsoft/dotnet:sdk
pool:
    demands:
    - C#
pipelines:
  branches:
    "{develop}":
      - step:
          name: Running SonarCloud Analysis
          caches:
            - sonar
          services:
            - docker
          script:
            - pipe: sonarsource/sonarcloud-scan:1.0.1
              variables:
                SONAR_TOKEN: My_token
                BITBUCKET_COMMIT: develop 
            - apt-get update
            - apt-get install --yes --force-yes openjdk-8-jre
            - export PATH="$PATH:/root/.dotnet/tools"
            - dotnet tool install --global dotnet-sonarscanner --version 4.8.0
            - dotnet tool run dotnet-sonarscanner begin /k:Project /d:"sonar.host.url=https://sonarcloud.io" /d:"sonar.login=My_login" /v:develop /o:Prokect_name
            - dotnet build Project.sln
            - dotnet sonarscanner end /d:"sonar.login= My_sonnar_login"
  pull-requests:
      '**': #this runs as default for any branch not elsewhere defined in this script
      - step:
          name: Running SonarCloud Analysis
          caches:
            - sonar
          services:
            - docker
          script:
            - pipe: sonarsource/sonarcloud-scan:1.0.1
              variables:
                SONAR_TOKEN: ${My_TOKEN}
            - apt-get update
            - apt-get install --yes --force-yes openjdk-8-jre
            - export PATH="$PATH:/root/.dotnet/tools"
            - dotnet tool install --global dotnet-sonarscanner
            - dotnet tool run dotnet-sonarscanner begin /k:Project /d:"sonar.host.url=https://sonarcloud.io" /d:"sonar.login=My_login" /v:develop /o:Prokect_name
            - dotnet build Project.sln
            - dotnet sonarscanner end /d:"sonar.login= My_login"
definitions:
  caches:
    sonar: ~/.sonar/cache
  services:
    docker:
      memory: 3072 # increase memory for docker-in-docker from 1GB to 3G

These are the Pipeline build error logs that might be relevant.

+ dotnet build Project.sln
Microsoft (R) Build Engine version 16.2.37902+b5aaefc9f for .NET Core
Copyright (C) Microsoft Corporation. All rights reserved.
  Nothing to do. None of the projects specified contain packages to restore.
/usr/share/dotnet/sdk/2.1.810/Microsoft.Common.CurrentVersion.targets(1175,5): error MSB3644: The reference assemblies for .NETFramework,Version=v4.7.2 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 [/opt/atlassian/pipelines/agent/build/ExLide/ExLide.csproj]
Build FAILED.
/usr/share/dotnet/sdk/2.1.810/Microsoft.Common.CurrentVersion.targets(1175,5): error MSB3644: The reference assemblies for .NETFramework,Version=v4.7.2 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 [/opt/atlassian/pipelines/agent/build/ExLide/ExLide.csproj]
    0 Warning(s)
    1 Error(s)

These are the console build error logs that might be relevant.

Determinando los proyectos que se van a restaurar...
  No hay nada que hacer. Ninguno de los proyectos especificados contiene paquetes para restaurar.
C:\Program Files\dotnet\sdk\3.1.402\Microsoft.Common.CurrentVersion.targets(2084,5): warning MSB3245: No se pudo resolver esta referencia. No se encuentra el ensamblado "Microsoft.Office.Tools.v4.0.Framework, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL". Compruebe si el ensamblado existe en el disco. Si el código necesita esta referencia, podrían producirse errores de compilación. [D:\EXlide\ms-vsto-extension\ExLide\ExLide.csproj]

Controllers\ComponentController.cs(5,32): error CS0234: El tipo o el nombre del espacio de nombres 'Interop' no existe en el espacio de nombres 'Microsoft.Office' (¿falta alguna referencia de ensamblado?) [D:\EXlide\ms-vsto-extension\ExLide\ExLide.csproj]

we have not been able to bring the indicators to sonarcloud.

Hi @Juan_David_Ruiz_Muri and welcome to the community.

I think at first this has nothing to do with SonarCloud, but more that you are using a docker image that doesn’t contain the .NET framework version you want, as per the log you shown.

Can you just simply, without SonarCloud, try to build your solution with the docker image, and then integrate SonarCloud on it ?

HTH,
Mickaël