Hello @xamarindev,
Your Xamarin project is built with MSBuild right? Analyzing an MSBuild project must be made with the SonarScanner for MSBuild, while here you tried to use the Scanner CLI directly. The reason is that the code analysis happens during the MSBuild process itself.
So I invite you to read our doc about the Scanner for MSBuild to understand more about how it works. Of course in an Azure pipeline, you have to use the SonarCloudPrepare and SonarCloudAnalyze tasks as you did, but select the Integrate with MSBuild option instead of Use standalone scanner.
Here is what looks like a simple Xamarin build (with one iOS and one Android build) with a SonarQube instance (it’s the same on SonarCloud, unless you use SonarCloud tasks):
pool:
name: Azure Pipelines
demands:
- Xamarin.iOS
- MSBuild
- Xamarin.Android
- java
steps:
- task: NuGetCommand@2
displayName: 'NuGet restore'
inputs:
restoreSolution: 'SkeletonApp/**/*.sln'
- task: SonarSource.sonarqube.15B84CA1-B62F-4A2A-A403-89B77A063157.SonarQubePrepare@4
displayName: 'Prepare analysis on SonarQube'
inputs:
SonarQube: 'Antoine MacOS SQ 7.9.3 with Ngrok'
projectKey: 'xamarin-test'
- task: XamariniOS@2
displayName: 'Build Xamarin.iOS solution SkeletonApp/**/*.sln'
inputs:
solutionFile: 'SkeletonApp/**/*.sln'
packageApp: false
args: '/p:Platform="Any CPU"'
- task: XamarinAndroid@1
displayName: 'Build Xamarin.Android project SkeletonApp/**/*.csproj'
inputs:
projectFile: 'SkeletonApp/**/*.csproj'
- task: SonarSource.sonarqube.6D01813A-9589-4B15-8491-8164AEB38055.SonarQubeAnalyze@4
displayName: 'Run Code Analysis'
- task: SonarSource.sonarqube.291ed61f-1ee4-45d3-b1b0-bf822d9095ef.SonarQubePublish@4
displayName: 'Publish Quality Gate Result'
Note that you don’t need a sonar-project.properties in this context, the Scanner for MSBuild will handle it on its own. Also none of the extra parameters you added are needed (like sonar.language
, sonar.sourceEncoding
, etc.), but if you need more parameter, you have an input to add them in the SonarCloudPrepare task.
I hope it will help.