Integrate Sonar Cloud

How to integrate Sonar Cloud in Bit Bucket for Xamarin Forms application ?

Hi @puneetk207 and welcome to the community.

Which kind of build technology are you using for Xamarin ? MSBuild ?

Mickaël

yes correct. MSBuild.

So then you would be interested by our SonarScanner for MSBuild

If you are using the Bitbucket pipelines to run your build, then you may be interested by the dotnet global tool that we ship on each release (documented above)

HTH,
Mickaël

Ok. Can you let me know how to integrate with bitbucket repository step by step ? I am not using bitbucket pipelines to run the build.

So then which CI tool are you using ? We are integrating with multiple ones.

No we don’t have any CI tool. We do build manually.

You can then at first create an account on SonarCloud (with your bitbucket login) and follow the first steps to setup a CI (there is a tutorial). We can then after add the proper scan to that “build”.

Ok. Let me try.

i created account on SonarCloud with bitbucket login. Can you please help me out in setup a CI or send me a tutorial ?

Hi @puneetk207,

You can then import your repository and create a SonarCloud project from it. Once that is done, you will have the possibility to follow tutorials directly on the project’s page to setup a first analysis.

HTH,

i am not able to see any repository link to my account.

Hi @mickaelcaro,

how to include Sonar scanner for MSBuild in bitbucket pipelines ?

Hi,

You can add the dotnet global tool that we ship as part of your pipeline (by first installing it, and then use it). Everything is documented in the link i gave you above

Hi @mickaelcaro, I understand but document is not too clear. I am using terminal in macOS to run the sonar cloud. What is my requirement let me describe here :-

  • Integrate sonar cloud for Xamarin Forms project which helps developer to see code quality while doing pull and push on bitbucket.

You can try also to follow a quick guide on this post : Bitbucket Pipe + SonarCloud + C#/.net core

It’s for dotnet core but you might be able to figure that out for Xamarin as well.

Let me know.

@mickaelcaro i tried doing above example but getting this error :-
dotnet tool install --global dotnet-sonarscanner
bash: dotnet: command not found

You need to use a dotnet sdk base image i guess.

@mickaelcaro While building the project i am getting this 7 errors(See below). I tried to resolve it but failed.

1- /opt/atlassian/pipelines/agent/build/KorMobileApplication/Android/KorMobileApplication.Android/KorMobileApplication.Android.csproj(2038,3): error MSB4019: The imported project “/usr/share/dotnet/sdk/2.1.808/Xamarin/Android/Xamarin.Android.CSharp.targets” was not found. Confirm that the path in the declaration is correct, and that the file exists on disk.

2-
/opt/atlassian/pipelines/agent/build/KorMobileApplication/Framework/KorMobileApplication.BackgroundService/KorMobileApplication.BackgroundService.csproj(62,3): error MSB4019: The imported project “/usr/share/dotnet/sdk/2.1.808/Xamarin/Android/Xamarin.Android.CSharp.targets” was not found. Confirm that the path in the declaration is correct, and that the file exists on disk.

3-
/opt/atlassian/pipelines/agent/build/KorMobileApplication/Android/KorMobileApplication.AndroidBluetoothFramework/KorMobileApplication.AndroidBTFramework.csproj(87,3): error MSB4019: The imported project “/usr/share/dotnet/sdk/2.1.808/Xamarin/Android/Xamarin.Android.CSharp.targets” was not found. Confirm that the path in the declaration is correct, and that the file exists on disk.

4-
/usr/share/dotnet/sdk/2.1.808/Microsoft.Common.CurrentVersion.targets(1175,5): error MSB3644: The reference assemblies for .NETFramework,Version=v4.6.1 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/KorMobileApplication/KorMobileApplication/KorMobileApplication.Common.Tests/KorMobileApplication.Common.Tests.csproj]

5-
/usr/share/dotnet/sdk/2.1.808/Microsoft.Common.CurrentVersion.targets(1175,5): error MSB3644: The reference assemblies for .NETFramework,Version=v4.6.1 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/KorMobileApplication/KorMobileApplication/KorMobileApplication.CalibrationEngine.Test/KorMobileApplication.CalibrationEngine.Test.csproj]

6-
/usr/share/dotnet/sdk/2.1.808/Microsoft.Common.CurrentVersion.targets(1175,5): error MSB3644: The reference assemblies for .NETFramework,Version=v4.6.1 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/KorMobileApplication/KorMobileApplication/KorMobileApplication.Controllers.Test/KorMobileApplication.Controllers.Test.csproj]

7-
/usr/share/dotnet/sdk/2.1.808/Microsoft.Common.CurrentVersion.targets(1175,5): error MSB3644: The reference assemblies for .NETFramework,Version=v4.6.1 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/KorMobileApplication/KorMobileApplication/KorMobileApplication.Shared.Test/KorMobileApplication.Shared.Test.csproj]

Can you show me your dockerfile and the pipeline config please ? Thanks !