Template for a good new topic, formatted with Markdown:
- ALM used (Azure DevOps)
- CI system used (Azure DevOps)
- Scanner command used MSBUILD
- Languages of the repository (C# / JS / TS)
- Error observed:
- If I use scanner mode MSBUILD then sonar analyses the c# code base but ignores the JS/TS code
- If I use scanner mode CLI then sonar analyses the JS/TS code base but ignores the C# code.
Pipeline YAML (CLI Mode)
- task: SonarCloudPrepare@1
displayName: 'Sonar Prep - CLI Mode'
inputs:
SonarCloud: 'MyProject-SonarCloud'
organization: 'MyOrg'
scannerMode: 'CLI'
configMode: 'manual'
cliProjectKey: 'MyProjectKey'
cliProjectName: 'MyProjectName'
cliSources: '.'
extraProperties: |
# Additional properties that will be passed to the scanner,
# Put one key=value per line, example:
sonar.exclusions=**/infrastructure/**/*,**/db_connect/**/*,**/docs/**/*,**/ETL/**/*,azure-pipelines.yml,myproject-cd.yml,README.md,sonarcloud-pipeline.yml,template-deploy-environment.yml
sonar.verbose=true
sonar.javascript.lcov.reportPaths=$(Build.Repository.LocalPath)/app/MyProject.UI/coverage/lcov.info
condition: or(eq(variables['Build.SourceBranch'], 'refs/heads/develop'), startsWith(variables['Build.SourceBranch'], 'refs/heads/cjn/'))
Pipeline YAML (MSBUILD Mode)
- task: SonarCloudPrepare@1
displayName: 'Prepare analysis on SonarCloud'
inputs:
SonarCloud: 'MyProject-SonarCloud'
organization: 'MyOrg'
projectKey: 'MyProjectKey'
projectName: 'MyProjectName'
extraProperties: |
sonar.exclusions=**/infrastructure/**/*,**/db_connect/**/*,**/docs/**/*,**/ETL/**/*,azure-pipelines.yml,customerportal-cd.yml,README.md,sonarcloud-pipeline.yml,template-deploy-environment.yml
sonar.cs.vstest.reportsPaths=$(Agent.TempDirectory)/*.trx
sonar.javascript.lcov.reportPaths=$(Build.Repository.LocalPath)/app/MyProject.UI/coverage/lcov.info
sonar.verbose=true
condition: or(eq(variables['Build.SourceBranch'], 'refs/heads/develop'), startsWith(variables['Build.SourceBranch'], 'refs/heads/cjn/'))
The CLI version reads all of the code base from both the app/<C#> and app/<js_ts> code but only reports on the JS/TS side of the code. The MSBUILD version only reads from the app/<C#> code and analyses that…
The JS/TS is built using NPM. whereas the C# code is built using a ‘DotNetCoreCLI@2’ task.
I’ve tried a bunch of things and the coverage files all seem to be located when it runs the analysis, I’m just not sure what I’m missing to get it to analyse them both together.
FYI, this is my 1st in-roads into sonarcloud so any help would be most appreciated.
EDIT: just noticed (on writing this post) that the sonar.vstest.reportsPaths variable is missing from the CLI run. Just retesting now.