Hide suddenly unwanted warning messages in Azure Pipelines

Hello,

We are using SonarQube-Cloud with AzureDevops and C# builds.

There is a bunch of auto generated code which we do not wish to scan with Sonar, so we excluded the folders using sonar.exclusions and sonar.coverage.exclusions;

- task: SonarCloudPrepare@4
  displayName: Prepare analysis on SonarCloud
  inputs:
    SonarCloud: "${{ parameters.sonarCloudServiceConnection }}"
    organization: "${{ parameters.SonarCloudOrganisation }}"
    projectKey: "${{ parameters.systemCode }}_${{ parameters.componentName }}"
    projectName: "${{ parameters.systemCode }} - ${{ parameters.repositoryName }} - ${{ parameters.componentName }}"
    projectVersion: "${{ parameters.semanticVersion }}"
    extraProperties: |
      sonar.cs.vstest.reportsPaths=$(Agent.TempDirectory)/**/*.trx
      sonar.tsql.file.suffixes=sql,tsql
      sonar.plsql.file.suffixes=pks,pkb

      # Code scope
      sonar.exclusions="$(GlobalSonarCloudExclusions),src/Architectuur/**,src/Development/**,src/Shared/**"
      sonar.inclusions=${{ parameters.sonarCloudInclusions }}
      sonar.coverage.exclusions=${{ parameters.sonarCloudCoverageExclusions }}
      sonar.cpd.exclusions=${{ parameters.sonarCloudDuplicationExclusions }}

      # Test scope
      sonar.test.exclusions="$(GlobalSonarCloudExclusions),src/Architectuur/**,src/Development/**,src/Shared/**"
      sonar.test.inclusions=${{ parameters.sonarCloudTestInclusions }}

      # Disable Multi-Language analysis
      sonar.scanner.scanAll=false

When running the pipeline, warnings are still being generated within the Azure Pipeline while the folders are excluded. The exclusions do not show up in Sonarqube-Cloud itself.

D:\a_work\27\s\src\Shared\xxxx.Nexus.Shared.Data.Core\Migrations\20250528140722_InitialMigration.cs(16,23): warning S1192: Define a constant instead of using this literal ‘register’ 425 times. () [D:\a_work\27\s\src\Shared\xxxx.Nexus.Shared.Data.Core\xxxx.Nexus.Shared.Data.Core.csproj]##[warning]src\Shared\xxxx.Nexus.Shared.Data.Core\Migrations\20250528140722_InitialMigration.cs(22,23): Warning S1192: Define a constant instead of using this literal ‘concept’ 42 times. ()D:\a_work\27\s\src\Shared\xxxx.Nexus.Shared.Data.Core\Migrations\20250528140722_InitialMigration.cs(22,23): warning S1192: Define a constant instead of using this literal ‘concept’ 42 times. () [D:\a_work\27\s\src\Shared\xxxx.Nexus.Shared.Data.Core\xxxx.Nexus.Shared.Data.Core.csproj]##[warning]src\Shared\xxxx.Nexus.Shared.Data.Core\Migrations\20250528140722_InitialMigration.cs(30,23): Warning S1192: Define a constant instead of using this literal ‘Aanvraagvergoedinghistorie’ 4 times. ()D:\a_work\27\s\src\Shared\xxxx.Nexus.Shared.Data.Core\Migrations\20250528140722_InitialMigration.cs(30,23): warning S1192: Define a constant instead of using this literal ‘Aanvraagvergoedinghistorie’ 4 times. () [D:\a_work\27\s\src\Shared\xxxx.Nexus.Shared.Data.Core\xxxx.Nexus.Shared.Data.Core.csproj]##[warning]src\Shared\xxxx.Nexus.Shared.Data.Core\Migrations\20250528140722_InitialMigration.cs(34,51): Warning S1192: Define a constant instead of using this literal ‘uniqueidentifier’ 180 times. ()

We have been experiencing these unwanted warnings suddenly since 14 November 2025.

It is possible to hide these warnings in the Azure Devops pipelines?

Hi,

Unfortunately with the SonarScanner for .NET (your only option for analyzing C# code) exclusions aren’t applied at the scanner, but only later, on the server.

 
Ann

2 Likes

Thank you for your reply Ann!

I created a feature request to address this clutter.

Dont generate warnings for exclusions in Azure Pipelines while analyzing C# code - Suggest new features - Sonar Community

1 Like