SonarQube causing build errors in .NET 6 project in Azure Pipelines

Must-share information (formatted with Markdown):

  • SonarQube 9.3.0.51899, SonarScanner for Azure DevOps 5.4.0
  • Scan .NET 6 projects in Azure Pipelines

Here is my SonarQubePrepare step:

- task: SonarQubePrepare@5
      inputs:
        SonarQube: 'Pipeline Sonarqube Connection'
        scannerMode: 'MSBuild'
        projectKey: 'xxxxxxxxxxxxxxxx'
        projectName: 'xxxxxxxxxxxxxxx'

When building with no SonarQube steps, the build succeeds without issue. When building with a SonarQube Prepare step, the build fails with an error regarding namespace issues for things that are definitely present (again, the exact same code builds without the SQ steps). Projects written in .NET Framework have not had this issue.

When running in diagnostic mode, I noticed that the SonarQubePrepare step is using the classic-sonar-scanner-msbuild and not the dotnet-sonar-scanner-msbuild from the hosted build agent’s tasks folder. I’m not sure if this is the cause, but it seems likely and I cannot find a way to force it to use one scanner over the other.

Can someone please shed some light on this?

Hello @jraneri welcome to the community!

We’ll need the logs, please give the output of running MSBuild in verbose mode ( /v:d )

All the best,

Čaba

Here are the logs from the SonarQubePrepare step (some data has been redacted):


2022-04-19T15:05:24.7293321Z ##[section]Starting: SonarQubePrepare
2022-04-19T15:05:24.7435716Z ==============================================================================
2022-04-19T15:05:24.7436021Z Task         : Prepare Analysis Configuration
2022-04-19T15:05:24.7436260Z Description  : Prepare SonarQube analysis configuration
2022-04-19T15:05:24.7436445Z Version      : 5.4.0
2022-04-19T15:05:24.7436626Z Author       : sonarsource
2022-04-19T15:05:24.7436917Z Help         : Version: 5.4.0. [More Information](http://redirect.sonarsource.com/doc/install-configure-scanner-tfs-ts.html)
2022-04-19T15:05:24.7437393Z ==============================================================================
2022-04-19T15:05:24.7500238Z ##[debug]Using node path: D:\Agents\MidstreamITSolutionDelivery\MDS6716\externals\node10\bin\node.exe
2022-04-19T15:05:24.9125385Z ##[debug]agent.TempDirectory=D:\Agents\MidstreamITSolutionDelivery\MDS6716\_work\_temp
2022-04-19T15:05:24.9152071Z ##[debug]loading inputs and endpoints
2022-04-19T15:05:24.9174654Z ##[debug]loading ENDPOINT_AUTH_5e07d844-96f8-4bec-a0aa-357900b785cf
2022-04-19T15:05:24.9190050Z ##[debug]loading ENDPOINT_AUTH_PARAMETER_5e07d844-96f8-4bec-a0aa-357900b785cf_USERNAME
2022-04-19T15:05:24.9193848Z ##[debug]loading ENDPOINT_AUTH_PARAMETER_SYSTEMVSSCONNECTION_ACCESSTOKEN
2022-04-19T15:05:24.9197030Z ##[debug]loading ENDPOINT_AUTH_SCHEME_5e07d844-96f8-4bec-a0aa-357900b785cf
2022-04-19T15:05:24.9200123Z ##[debug]loading ENDPOINT_AUTH_SCHEME_SYSTEMVSSCONNECTION
2022-04-19T15:05:24.9211827Z ##[debug]loading ENDPOINT_AUTH_SYSTEMVSSCONNECTION
2022-04-19T15:05:24.9215163Z ##[debug]loading INPUT_CLIPROJECTVERSION
2022-04-19T15:05:24.9217305Z ##[debug]loading INPUT_CLISOURCES
2022-04-19T15:05:24.9219309Z ##[debug]loading INPUT_CONFIGFILE
2022-04-19T15:05:24.9221396Z ##[debug]loading INPUT_CONFIGMODE
2022-04-19T15:05:24.9223258Z ##[debug]loading INPUT_EXTRAPROPERTIES
2022-04-19T15:05:24.9225177Z ##[debug]loading INPUT_PROJECTKEY
2022-04-19T15:05:24.9226997Z ##[debug]loading INPUT_PROJECTNAME
2022-04-19T15:05:24.9228759Z ##[debug]loading INPUT_PROJECTVERSION
2022-04-19T15:05:24.9230583Z ##[debug]loading INPUT_SCANNERMODE
2022-04-19T15:05:24.9232475Z ##[debug]loading INPUT_SONARQUBE
2022-04-19T15:05:24.9237747Z ##[debug]loading SECRET_AGENT_PROXYPASSWORD
2022-04-19T15:05:24.9240504Z ##[debug]loading SECRET_DEPLOYMENTPASSWORD
2022-04-19T15:05:24.9242547Z ##[debug]loading SECRET_SYSTEM_ACCESSTOKEN
2022-04-19T15:05:24.9247829Z ##[debug]loaded 19
2022-04-19T15:05:24.9252606Z ##[debug]Agent.ProxyUrl=<Proxy URL>
2022-04-19T15:05:24.9253081Z ##[debug]Agent.ProxyUsername=MGROUPNET\svc-dotnetbuild
2022-04-19T15:05:24.9260098Z ##[debug]Agent.ProxyPassword=***
2022-04-19T15:05:24.9260509Z ##[debug]Agent.ProxyBypassList=undefined
2022-04-19T15:05:24.9264200Z ##[debug]Agent.TempDirectory=D:\Agents\MidstreamITSolutionDelivery\MDS6716\_work\_temp
2022-04-19T15:05:24.9289470Z ##[debug]expose agent proxy configuration.
2022-04-19T15:05:24.9290373Z ##[debug]Agent.CAInfo=undefined
2022-04-19T15:05:24.9290787Z ##[debug]Agent.ClientCert=undefined
2022-04-19T15:05:24.9291167Z ##[debug]Agent.SkipCertValidation=undefined
2022-04-19T15:05:25.2872181Z ##[debug]SonarQube=5e07d844-96f8-4bec-a0aa-357900b785cf
2022-04-19T15:05:25.2873122Z ##[debug]5e07d844-96f8-4bec-a0aa-357900b785cf=<SonarQube URL>/
2022-04-19T15:05:25.2873875Z ##[debug]5e07d844-96f8-4bec-a0aa-357900b785cf auth param apitoken = undefined
2022-04-19T15:05:25.2877642Z ##[debug]5e07d844-96f8-4bec-a0aa-357900b785cf auth param username = ***
2022-04-19T15:05:25.2878405Z ##[debug]5e07d844-96f8-4bec-a0aa-357900b785cf auth param password = undefined
2022-04-19T15:05:25.2878990Z ##[debug]organization=undefined
2022-04-19T15:05:25.2884987Z ##[debug]scannerMode=MSBuild
2022-04-19T15:05:25.2887718Z ##[debug]projectKey=<Project Name>
2022-04-19T15:05:25.2889425Z ##[debug]projectName=Pipeline-<Project Name>
2022-04-19T15:05:25.2891293Z ##[debug]projectVersion=1.0
2022-04-19T15:05:25.2891874Z ##[debug]organization=undefined
2022-04-19T15:05:25.2894160Z ##[debug][SQ] API GET: '/api/server/version' with query "undefined"
2022-04-19T15:05:25.2946749Z (node:4604) Warning: Use Cipheriv for counter mode of aes-256-ctr
2022-04-19T15:05:25.3520906Z ##[debug]Response: 200 Body: "9.3.0.51899"
2022-04-19T15:05:25.3531817Z ##[debug]System.TeamFoundationCollectionUri=<ADO Url>
2022-04-19T15:05:25.3533497Z ##[debug]System.PullRequest.PullRequestId=undefined
2022-04-19T15:05:25.3534947Z ##[debug]Build.Repository.Provider=TfsGit
2022-04-19T15:05:25.3536880Z ##[debug]Build.SourceBranch=refs/heads/dev
2022-04-19T15:05:25.3538225Z ##[debug]SYSTEMVSSCONNECTION exists true
2022-04-19T15:05:25.8940698Z ##[debug]Build.Repository.Name=<Project Name>
2022-04-19T15:05:25.8942053Z ##[debug]System.TeamProject=Pipeline
2022-04-19T15:05:26.1259547Z ##[debug]Default branch of this repository is 'refs/heads/main'
2022-04-19T15:05:26.1260853Z ##[debug]Build.SourceBranch=refs/heads/dev
2022-04-19T15:05:26.1261921Z ##[debug]SonarCloud or SonarQube version >= 7.2.0 detected, setting report-task.txt file to its newest location.
2022-04-19T15:05:26.1263324Z ##[debug]Agent.TempDirectory=D:\Agents\MidstreamITSolutionDelivery\MDS6716\_work\_temp
2022-04-19T15:05:26.1264579Z ##[debug]Build.BuildNumber=22.1.0-dev.40
2022-04-19T15:05:26.1265599Z ##[debug][SQ] Branch and PR parameters: {"sonar.branch.name":"dev","sonar.scanner.metadataFilePath":"D:\\Agents\\MidstreamITSolutionDelivery\\MDS6716\\_work\\_temp\\sonar\\22.1.0-dev.40\\82080153-9d5d-9f72-9c4f-5b249ef9e042\\report-task.txt"}
2022-04-19T15:05:26.1268740Z ##[debug]extraProperties=# Additional properties that will be passed to the scanner, 
# Put one key=value per line, example:
# sonar.exclusions=**/*.bin
2022-04-19T15:05:26.1270173Z ##[debug]set SONARQUBE_SCANNER_MODE=MSBuild
2022-04-19T15:05:26.1274022Z ##[debug]Processed: ##vso[task.setvariable variable=SONARQUBE_SCANNER_MODE;isOutput=false;issecret=false;]MSBuild
2022-04-19T15:05:26.1274918Z ##[debug]set SONARQUBE_ENDPOINT=********
2022-04-19T15:05:26.1282155Z ##[debug]Processed: ##vso[task.setvariable variable=SONARQUBE_ENDPOINT;isOutput=false;issecret=true;]***
2022-04-19T15:05:26.1284207Z ##[debug]set SONARQUBE_SCANNER_PARAMS={"sonar.host.url":"<SonarQube URL>/","sonar.login":***,"sonar.projectKey":"<Project Name>","sonar.projectName":"Pipeline-<Project Name>","sonar.projectVersion":"1.0","sonar.branch.name":"dev","sonar.scanner.metadataFilePath":"D:\\Agents\\MidstreamITSolutionDelivery\\MDS6716\\_work\\_temp\\sonar\\22.1.0-dev.40\\82080153-9d5d-9f72-9c4f-5b249ef9e042\\report-task.txt"}
2022-04-19T15:05:26.1288710Z ##[debug]Processed: ##vso[task.setvariable variable=SONARQUBE_SCANNER_PARAMS;isOutput=false;issecret=false;]{"sonar.host.url":"<SonarQube URL>/","sonar.login":***,"sonar.projectKey":"<Project Name>","sonar.projectName":"Pipeline-<Project Name>","sonar.projectVersion":"1.0","sonar.branch.name":"dev","sonar.scanner.metadataFilePath":"D:\\Agents\\MidstreamITSolutionDelivery\\MDS6716\\_work\\_temp\\sonar\\22.1.0-dev.40\\82080153-9d5d-9f72-9c4f-5b249ef9e042\\report-task.txt"}
2022-04-19T15:05:26.1290869Z ##[debug]Absolute path for pathSegments: D:\Agents\MidstreamITSolutionDelivery\MDS6716\_work\_tasks\SonarQubePrepare_15b84ca1-b62f-4a2a-a403-89b77a063157\5.4.0,classic-sonar-scanner-msbuild,SonarScanner.MSBuild.exe = D:\Agents\MidstreamITSolutionDelivery\MDS6716\_work\_tasks\SonarQubePrepare_15b84ca1-b62f-4a2a-a403-89b77a063157\5.4.0\classic-sonar-scanner-msbuild\SonarScanner.MSBuild.exe
2022-04-19T15:05:26.1293188Z ##[debug]Using classic scanner at D:\Agents\MidstreamITSolutionDelivery\MDS6716\_work\_tasks\SonarQubePrepare_15b84ca1-b62f-4a2a-a403-89b77a063157\5.4.0\classic-sonar-scanner-msbuild\SonarScanner.MSBuild.exe
2022-04-19T15:05:26.1294406Z ##[debug]set SONARQUBE_SCANNER_MSBUILD_EXE=D:\Agents\MidstreamITSolutionDelivery\MDS6716\_work\_tasks\SonarQubePrepare_15b84ca1-b62f-4a2a-a403-89b77a063157\5.4.0\classic-sonar-scanner-msbuild\SonarScanner.MSBuild.exe
2022-04-19T15:05:26.1296148Z ##[debug]Processed: ##vso[task.setvariable variable=SONARQUBE_SCANNER_MSBUILD_EXE;isOutput=false;issecret=false;]D:\Agents\MidstreamITSolutionDelivery\MDS6716\_work\_tasks\SonarQubePrepare_15b84ca1-b62f-4a2a-a403-89b77a063157\5.4.0\classic-sonar-scanner-msbuild\SonarScanner.MSBuild.exe
2022-04-19T15:05:26.1297359Z ##[debug]which 'D:\Agents\MidstreamITSolutionDelivery\MDS6716\_work\_tasks\SonarQubePrepare_15b84ca1-b62f-4a2a-a403-89b77a063157\5.4.0\classic-sonar-scanner-msbuild\SonarScanner.MSBuild.exe'
2022-04-19T15:05:26.1301779Z ##[debug]found: 'D:\Agents\MidstreamITSolutionDelivery\MDS6716\_work\_tasks\SonarQubePrepare_15b84ca1-b62f-4a2a-a403-89b77a063157\5.4.0\classic-sonar-scanner-msbuild\SonarScanner.MSBuild.exe'
2022-04-19T15:05:26.1302775Z ##[debug]D:\Agents\MidstreamITSolutionDelivery\MDS6716\_work\_tasks\SonarQubePrepare_15b84ca1-b62f-4a2a-a403-89b77a063157\5.4.0\classic-sonar-scanner-msbuild\SonarScanner.MSBuild.exe arg: begin
2022-04-19T15:05:26.1303722Z ##[debug]D:\Agents\MidstreamITSolutionDelivery\MDS6716\_work\_tasks\SonarQubePrepare_15b84ca1-b62f-4a2a-a403-89b77a063157\5.4.0\classic-sonar-scanner-msbuild\SonarScanner.MSBuild.exe arg: /k:<Project Name>
2022-04-19T15:05:26.1304451Z ##[debug]system.debug=true
2022-04-19T15:05:26.1305057Z ##[debug]D:\Agents\MidstreamITSolutionDelivery\MDS6716\_work\_tasks\SonarQubePrepare_15b84ca1-b62f-4a2a-a403-89b77a063157\5.4.0\classic-sonar-scanner-msbuild\SonarScanner.MSBuild.exe arg: /d:sonar.verbose=true
2022-04-19T15:05:26.1306586Z ##[debug]exec tool: D:\Agents\MidstreamITSolutionDelivery\MDS6716\_work\_tasks\SonarQubePrepare_15b84ca1-b62f-4a2a-a403-89b77a063157\5.4.0\classic-sonar-scanner-msbuild\SonarScanner.MSBuild.exe
2022-04-19T15:05:26.1307565Z ##[debug]arguments:
2022-04-19T15:05:26.1307938Z ##[debug]   begin
2022-04-19T15:05:26.1308310Z ##[debug]   /k:<Project Name>
2022-04-19T15:05:26.1308683Z ##[debug]   /d:sonar.verbose=true
2022-04-19T15:05:26.1313069Z [command]D:\Agents\MidstreamITSolutionDelivery\MDS6716\_work\_tasks\SonarQubePrepare_15b84ca1-b62f-4a2a-a403-89b77a063157\5.4.0\classic-sonar-scanner-msbuild\SonarScanner.MSBuild.exe begin /k:<Project Name> /d:sonar.verbose=true
2022-04-19T15:05:26.7768103Z SonarScanner for MSBuild 5.5.3
>>>>>>   2022-04-19T15:05:26.7768944Z Using the .NET Framework version of the Scanner for MSBuild <<<<<<
2022-04-19T15:05:26.7769649Z Default properties file was found at D:\Agents\MidstreamITSolutionDelivery\MDS6716\_work\_tasks\SonarQubePrepare_15b84ca1-b62f-4a2a-a403-89b77a063157\5.4.0\classic-sonar-scanner-msbuild\SonarQube.Analysis.xml
2022-04-19T15:05:26.7770621Z Loading analysis properties from D:\Agents\MidstreamITSolutionDelivery\MDS6716\_work\_tasks\SonarQubePrepare_15b84ca1-b62f-4a2a-a403-89b77a063157\5.4.0\classic-sonar-scanner-msbuild\SonarQube.Analysis.xml
2022-04-19T15:05:26.7771322Z sonar.verbose=true was specified - setting the log verbosity to 'Debug'
2022-04-19T15:05:26.7771585Z Pre-processing started.
2022-04-19T15:05:26.7771801Z Preparing working directories...
2022-04-19T15:05:26.7772054Z Using environment variables to determine the download directory...
2022-04-19T15:05:26.7772441Z Using environment variable 'AGENT_BUILDDIRECTORY', value 'D:\Agents\MidstreamITSolutionDelivery\MDS6716\_work\149'
2022-04-19T15:05:26.7773057Z 09:05:26.276  09:05:26.26  Loading analysis properties from D:\Agents\MidstreamITSolutionDelivery\MDS6716\_work\_tasks\SonarQubePrepare_15b84ca1-b62f-4a2a-a403-89b77a063157\5.4.0\classic-sonar-scanner-msbuild\SonarQube.Analysis.xml
2022-04-19T15:05:26.7774288Z 09:05:26.276  09:05:26.276  sonar.verbose=true was specified - setting the log verbosity to 'Debug'
2022-04-19T15:05:26.7774617Z 09:05:26.276  Updating build integration targets...
2022-04-19T15:05:26.7775096Z 09:05:26.276  The file SonarQube.Integration.ImportBefore.targets is up to date at C:\Users\svc-dotnetbuild\AppData\Local\Microsoft\MSBuild\4.0\Microsoft.Common.targets\ImportBefore
2022-04-19T15:05:26.7775746Z 09:05:26.276  The file SonarQube.Integration.ImportBefore.targets is up to date at C:\Users\svc-dotnetbuild\AppData\Local\Microsoft\MSBuild\10.0\Microsoft.Common.targets\ImportBefore
2022-04-19T15:05:26.7776389Z 09:05:26.276  The file SonarQube.Integration.ImportBefore.targets is up to date at C:\Users\svc-dotnetbuild\AppData\Local\Microsoft\MSBuild\11.0\Microsoft.Common.targets\ImportBefore
2022-04-19T15:05:26.7777025Z 09:05:26.276  The file SonarQube.Integration.ImportBefore.targets is up to date at C:\Users\svc-dotnetbuild\AppData\Local\Microsoft\MSBuild\12.0\Microsoft.Common.targets\ImportBefore
2022-04-19T15:05:26.7777655Z 09:05:26.276  The file SonarQube.Integration.ImportBefore.targets is up to date at C:\Users\svc-dotnetbuild\AppData\Local\Microsoft\MSBuild\14.0\Microsoft.Common.targets\ImportBefore
2022-04-19T15:05:26.7778432Z 09:05:26.276  The file SonarQube.Integration.ImportBefore.targets is up to date at C:\Users\svc-dotnetbuild\AppData\Local\Microsoft\MSBuild\15.0\Microsoft.Common.targets\ImportBefore
2022-04-19T15:05:26.7779345Z 09:05:26.276  The file SonarQube.Integration.ImportBefore.targets is up to date at C:\Users\svc-dotnetbuild\AppData\Local\Microsoft\MSBuild\Current\Microsoft.Common.targets\ImportBefore
2022-04-19T15:05:26.7780193Z 09:05:26.276  Installed SonarQube.Integration.targets to D:\Agents\MidstreamITSolutionDelivery\MDS6716\_work\149\.sonarqube\bin\targets
2022-04-19T15:05:26.7780816Z 09:05:26.276  Creating config and output folders...
2022-04-19T15:05:26.7781346Z 09:05:26.276  Creating directory: D:\Agents\MidstreamITSolutionDelivery\MDS6716\_work\149\.sonarqube\conf
2022-04-19T15:05:26.7781979Z 09:05:26.276  Creating directory: D:\Agents\MidstreamITSolutionDelivery\MDS6716\_work\149\.sonarqube\out
2022-04-19T15:05:26.7782606Z 09:05:26.307  Downloading from <SonarQube URL>/api/server/version...
2022-04-19T15:05:26.7783512Z 09:05:26.37  Checking validity of server license
2022-04-19T15:05:26.7784019Z 09:05:26.37  Downloading from <SonarQube URL>/api/editions/is_valid_license...
2022-04-19T15:05:26.7784590Z 09:05:26.479  SonarQube Community Edition detected, license is valid.
2022-04-19T15:05:26.7784997Z 09:05:26.495  Fetching analysis configuration settings...
2022-04-19T15:05:26.7785637Z 09:05:26.495  Fetching properties for project '<Project Name>' from <SonarQube URL>/api/settings/values?component=<Project Name>...
2022-04-19T15:05:26.7786376Z 09:05:26.495  Downloading from <SonarQube URL>/api/settings/values?component=<Project Name>...
2022-04-19T15:05:26.7786971Z 09:05:26.76  Downloading from <SonarQube URL>/api/languages/list...
2022-04-19T15:05:26.8735017Z 09:05:26.87  Fetching quality profile for project '<Project Name>' from <SonarQube URL>/api/qualityprofiles/search?project=<Project Name>...
2022-04-19T15:05:26.8757611Z 09:05:26.87  Downloading from <SonarQube URL>/api/qualityprofiles/search?project=<Project Name>...
2022-04-19T15:05:27.2122346Z 09:05:27.198  Fetching rules for quality profile 'AX_Qipx5V5s-f_Gw_T5k' from <SonarQube URL>/api/rules/search?f=repo,name,severity,lang,internalKey,templateKey,params,actives&ps=500&qprofile=AX_Qipx5V5s-f_Gw_T5k&p=1...
2022-04-19T15:05:27.2135142Z 09:05:27.198  Downloading from <SonarQube URL>/api/rules/search?f=repo,name,severity,lang,internalKey,templateKey,params,actives&ps=500&qprofile=AX_Qipx5V5s-f_Gw_T5k&p=1...
2022-04-19T15:05:27.5304746Z 09:05:27.526  Local analyzer cache: C:\Users\svc-dotnetbuild\AppData\Local\Temp\.sonarqube\resources
2022-04-19T15:05:27.5364078Z 09:05:27.526  Writing Roslyn generated ruleset to D:\Agents\MidstreamITSolutionDelivery\MDS6716\_work\149\.sonarqube\conf\Sonar-cs.ruleset...
2022-04-19T15:05:27.5484858Z 09:05:27.542  Writing Roslyn generated ruleset to D:\Agents\MidstreamITSolutionDelivery\MDS6716\_work\149\.sonarqube\conf\Sonar-cs-none.ruleset...
2022-04-19T15:05:27.5522318Z 09:05:27.542  Provisioning analyzer assemblies for cs...
2022-04-19T15:05:27.5532387Z 09:05:27.542  Installing required Roslyn analyzers...
2022-04-19T15:05:27.5537084Z 09:05:27.542  Processing plugin: csharp version 8.34.0.42011
2022-04-19T15:05:27.5675356Z 09:05:27.557  Cache hit: using plugin files from C:\Users\svc-dotnetbuild\AppData\Local\Temp\.sonarqube\resources\0
2022-04-19T15:05:27.5677015Z 09:05:27.557  Processing plugin: vbnet version 8.34.0.42011
2022-04-19T15:05:27.5683817Z 09:05:27.557  Cache hit: using plugin files from C:\Users\svc-dotnetbuild\AppData\Local\Temp\.sonarqube\resources\1
2022-04-19T15:05:27.5742078Z 09:05:27.573  Writing Roslyn analyzer additional file to D:\Agents\MidstreamITSolutionDelivery\MDS6716\_work\149\.sonarqube\conf\cs\SonarLint.xml...
2022-04-19T15:05:27.5756191Z 09:05:27.573  Fetching quality profile for project '<Project Name>' from <SonarQube URL>/api/qualityprofiles/search?project=<Project Name>...
2022-04-19T15:05:27.5757026Z 09:05:27.573  Downloading from <SonarQube URL>/api/qualityprofiles/search?project=<Project Name>...
2022-04-19T15:05:27.9364069Z 09:05:27.932  Fetching rules for quality profile 'AX_QisgdV5s-f_Gw_UoN' from <SonarQube URL>/api/rules/search?f=repo,name,severity,lang,internalKey,templateKey,params,actives&ps=500&qprofile=AX_QisgdV5s-f_Gw_UoN&p=1...
2022-04-19T15:05:27.9365349Z 09:05:27.932  Downloading from <SonarQube URL>/api/rules/search?f=repo,name,severity,lang,internalKey,templateKey,params,actives&ps=500&qprofile=AX_QisgdV5s-f_Gw_UoN&p=1...
2022-04-19T15:05:28.2353014Z 09:05:28.229  Local analyzer cache: C:\Users\svc-dotnetbuild\AppData\Local\Temp\.sonarqube\resources
2022-04-19T15:05:28.2354499Z 09:05:28.229  Writing Roslyn generated ruleset to D:\Agents\MidstreamITSolutionDelivery\MDS6716\_work\149\.sonarqube\conf\Sonar-vbnet.ruleset...
2022-04-19T15:05:28.2366237Z 09:05:28.229  Writing Roslyn generated ruleset to D:\Agents\MidstreamITSolutionDelivery\MDS6716\_work\149\.sonarqube\conf\Sonar-vbnet-none.ruleset...
2022-04-19T15:05:28.2374893Z 09:05:28.229  Provisioning analyzer assemblies for vbnet...
2022-04-19T15:05:28.2375273Z 09:05:28.229  Installing required Roslyn analyzers...
2022-04-19T15:05:28.2375564Z 09:05:28.229  Processing plugin: csharp version 8.34.0.42011
2022-04-19T15:05:28.2381247Z 09:05:28.229  Cache hit: using plugin files from C:\Users\svc-dotnetbuild\AppData\Local\Temp\.sonarqube\resources\0
2022-04-19T15:05:28.2381650Z 09:05:28.229  Processing plugin: vbnet version 8.34.0.42011
2022-04-19T15:05:28.2386621Z 09:05:28.229  Cache hit: using plugin files from C:\Users\svc-dotnetbuild\AppData\Local\Temp\.sonarqube\resources\1
2022-04-19T15:05:28.2398969Z 09:05:28.229  Writing Roslyn analyzer additional file to D:\Agents\MidstreamITSolutionDelivery\MDS6716\_work\149\.sonarqube\conf\vbnet\SonarLint.xml...
2022-04-19T15:05:28.2625796Z 09:05:28.26  Pre-processing succeeded.
2022-04-19T15:05:28.2711677Z ##[debug]Exit code 0 received from tool 'D:\Agents\MidstreamITSolutionDelivery\MDS6716\_work\_tasks\SonarQubePrepare_15b84ca1-b62f-4a2a-a403-89b77a063157\5.4.0\classic-sonar-scanner-msbuild\SonarScanner.MSBuild.exe'
2022-04-19T15:05:28.2713303Z ##[debug]STDIO streams have closed for tool 'D:\Agents\MidstreamITSolutionDelivery\MDS6716\_work\_tasks\SonarQubePrepare_15b84ca1-b62f-4a2a-a403-89b77a063157\5.4.0\classic-sonar-scanner-msbuild\SonarScanner.MSBuild.exe'
2022-04-19T15:05:28.2805165Z ##[section]Finishing: SonarQubePrepare

This seems to only be an issue with .NET 6 projects using Razor pages as I realized after my initial post that another project I added successfully was .NET 6 but didn’t use Razor. I’ve marked the line in the logs where it states that it is using the .NET Framework version of the scanner with >>>>><<<<<.

Thanks,
Josh

Using the <UseRazorSourceGenerator>false</UseRazorSourceGenerator> workaround that I found allows it to build, but wasn’t this issue supposed to have been fixed in the February update?

Hello @jraneri

Could you please share with me what is the value of the sonar.cs.roslyn.ignoreIssues parameter on your side?

And also could you please share the detailed msbuild logs? You can do it by using one of the following commands:

MsBuild.exe /t:Rebuild /v:d

or

dotnet build -v:d

All the best,
Čaba

The logs are thousands of lines long, but I’ll post the relevant sections. As I said, when there are no SonarQube steps in the pipeline, the project builds just fine. When the SonarQube steps are added, it throws 41 errors related to .razor.cs files:

##[warning]MW.Tas.DataManager.Web\MW.Tas.DataManager.Web\Api\ValuesController.cs(22,20): Warning CS0108: 'ValuesController.User' hides inherited member 'ControllerBase.User'. Use the new keyword if hiding was intended.

D:\Agents\MidstreamITSolutionDelivery\MDS6716\_work\179\s\MW.Tas.DataManager.Web\MW.Tas.DataManager.Web\Api\ValuesController.cs(22,20): warning CS0108: 'ValuesController.User' hides inherited member 'ControllerBase.User'. Use the new keyword if hiding was intended. [D:\Agents\MidstreamITSolutionDelivery\MDS6716\_work\179\s\MW.Tas.DataManager.Web\MW.Tas.DataManager.Web\MW.Tas.DataManager.Web.csproj]

##[error]MW.Tas.DataManager.Web\MW.Tas.DataManager.Web\App.razor.cs(23,26): Error CS0115: 'App.OnInitialized()': no suitable method found to override

D:\Agents\MidstreamITSolutionDelivery\MDS6716\_work\179\s\MW.Tas.DataManager.Web\MW.Tas.DataManager.Web\App.razor.cs(23,26): error CS0115: 'App.OnInitialized()': no suitable method found to override [D:\Agents\MidstreamITSolutionDelivery\MDS6716\_work\179\s\MW.Tas.DataManager.Web\MW.Tas.DataManager.Web\MW.Tas.DataManager.Web.csproj]

##[error]MW.Tas.DataManager.Web\MW.Tas.DataManager.Web\Pages\AboutDialog.razor.cs(9,26): Error CS0115: 'AboutDialog.OnInitialized()': no suitable method found to override

D:\Agents\MidstreamITSolutionDelivery\MDS6716\_work\179\s\MW.Tas.DataManager.Web\MW.Tas.DataManager.Web\Pages\AboutDialog.razor.cs(9,26): error CS0115: 'AboutDialog.OnInitialized()': no suitable method found to override [D:\Agents\MidstreamITSolutionDelivery\MDS6716\_work\179\s\MW.Tas.DataManager.Web\MW.Tas.DataManager.Web\MW.Tas.DataManager.Web.csproj]

##[error]MW.Tas.DataManager.Web\MW.Tas.DataManager.Web\Shared\Error.razor.cs(14,26): Error CS0115: 'Error.OnInitialized()': no suitable method found to override

D:\Agents\MidstreamITSolutionDelivery\MDS6716\_work\179\s\MW.Tas.DataManager.Web\MW.Tas.DataManager.Web\Shared\Error.razor.cs(14,26): error CS0115: 'Error.OnInitialized()': no suitable method found to override [D:\Agents\MidstreamITSolutionDelivery\MDS6716\_work\179\s\MW.Tas.DataManager.Web\MW.Tas.DataManager.Web\MW.Tas.DataManager.Web.csproj]

##[error]MW.Tas.DataManager.Web\MW.Tas.DataManager.Web\Pages\CarrierDialog.razor.cs(13,26): Error CS0115: 'CarrierDialog.OnInitialized()': no suitable method found to override

D:\Agents\MidstreamITSolutionDelivery\MDS6716\_work\179\s\MW.Tas.DataManager.Web\MW.Tas.DataManager.Web\Pages\CarrierDialog.razor.cs(13,26): error CS0115: 'CarrierDialog.OnInitialized()': no suitable method found to override [D:\Agents\MidstreamITSolutionDelivery\MDS6716\_work\179\s\MW.Tas.DataManager.Web\MW.Tas.DataManager.Web\MW.Tas.DataManager.Web.csproj]

##[error]MW.Tas.DataManager.Web\MW.Tas.DataManager.Web\Pages\Carriers.razor.cs(8,32): Error CS0115: 'Carriers.OnInitializedAsync()': no suitable method found to override

D:\Agents\MidstreamITSolutionDelivery\MDS6716\_work\179\s\MW.Tas.DataManager.Web\MW.Tas.DataManager.Web\Pages\Carriers.razor.cs(8,32): error CS0115: 'Carriers.OnInitializedAsync()': no suitable method found to override [D:\Agents\MidstreamITSolutionDelivery\MDS6716\_work\179\s\MW.Tas.DataManager.Web\MW.Tas.DataManager.Web\MW.Tas.DataManager.Web.csproj]

When the Razor Source Generator workaround is used, it becomes a single error about not being able to find a single class in another folder:

D:\Agents\MidstreamITSolutionDelivery\MDS6716\_work\179\s\MW.Tas.DataManager.Web\MW.Tas.DataManager.Web\Pages\SqlScriptUpdate.razor.cs(14,2): warning S1185: Remove this method 'OnInitialized' to simply inherit its behavior. [D:\Agents\MidstreamITSolutionDelivery\MDS6716\_work\179\s\MW.Tas.DataManager.Web\MW.Tas.DataManager.Web\MW.Tas.DataManager.Web.csproj]
  Sonar: (MW.Tas.DataManager.Web.csproj) Project processed successfully
  Sonar: Preparing for Razor compilation, moved files (D:\Agents\MidstreamITSolutionDelivery\MDS6716\_work\179\.sonarqube\out\6\Issues.json;D:\Agents\MidstreamITSolutionDelivery\MDS6716\_work\179\.sonarqube\out\6\output-cs\file-metadata.pb;D:\Agents\MidstreamITSolutionDelivery\MDS6716\_work\179\.sonarqube\out\6\output-cs\log.pb;D:\Agents\MidstreamITSolutionDelivery\MDS6716\_work\179\.sonarqube\out\6\output-cs\metrics.pb;D:\Agents\MidstreamITSolutionDelivery\MDS6716\_work\179\.sonarqube\out\6\output-cs\symrefs.pb;D:\Agents\MidstreamITSolutionDelivery\MDS6716\_work\179\.sonarqube\out\6\output-cs\token-cpd.pb;D:\Agents\MidstreamITSolutionDelivery\MDS6716\_work\179\.sonarqube\out\6\output-cs\token-type.pb;D:\Agents\MidstreamITSolutionDelivery\MDS6716\_work\179\.sonarqube\out\6\ProjectInfo.xml) to D:\Agents\MidstreamITSolutionDelivery\MDS6716\_work\179\.sonarqube\out\6.tmp.
##[error]MW.Tas.DataManager.Web\MW.Tas.DataManager.Web\Pages\_Host.cshtml(26,10): Error CS0103: The name 'WebHelper' does not exist in the current context
D:\Agents\MidstreamITSolutionDelivery\MDS6716\_work\179\s\MW.Tas.DataManager.Web\MW.Tas.DataManager.Web\Pages\_Host.cshtml(26,10): error CS0103: The name 'WebHelper' does not exist in the current context [D:\Agents\MidstreamITSolutionDelivery\MDS6716\_work\179\s\MW.Tas.DataManager.Web\MW.Tas.DataManager.Web\MW.Tas.DataManager.Web.csproj]

Build FAILED.

The workaround worked just fine for the other .NET 6 Razor projects, but this one seems problematic for some reason.

@jraneri

With only this small section of logs we cannot do a proper investigation. Could you please send us the full verbose logs and also tell us what is the value of the sonar.cs.roslyn.ignoreIssues parameter?