How to install SonarScanner for .NET with SonarCloud and BitbucketCloud?

I’m new to SonarCloud. I was able to setup my Swift project scan but I am having issues setting up my C# (.net Framework) project.

I added these lines to my pipeline yml file
- SonarScanner.MSBuild.exe begin /k:“my key” /o:“my organisation” /d:sonar.login=“my token”
- MSBuild.exe xxxx.sln /t:Rebuild
- SonarScanner.MSBuild.exe end /d:sonar.login=“My token”

But when I run the pipeline I get a “SonarScanner.MSBuild.exe: command not found” error.

How do I install MSBuild ?
Is it scripted in the bitbucket pipeline yml file ?

I use both SonarCloud and Bitbucket cloud. Nothing installed on my premises.

OK, looks like I need to install MSBuild in the Bitbucket pipeline docker before I can call MSBuild.
Since the docker is on linux, is it possible to build my .net Framework app ?
I think I need to use mono but I’m really not familiar with linux environments.

Also, there might be a prebuild docker image somewhere?

Hi @regis

Can you check this post, test on your side and tell us if that helps ?

Thank you.

I will give it a try but my project is in C# .net framework, not .net core.

You’re right. I don’t think it’s currently possible to pull a windows-based image on BitBucket right now. So it might be tricky to setup a “mono” build image on linux, not impossible though.

I might suggest you to move this pipeline on Azure DevOps (not the code, only the pipeline), which has better support for those kind of solutions.


1 Like


I will try and let you know how it goes.

I was able to scan my C# .Net Framework using an Azure DevOps Pipeline. Thank you for the tip.

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.