jvilimek
(Jan Vilimek)
May 3, 2021, 3:33pm
1
We have a .NET 5 project in Azure DevOps we have analyzed with SonarCloud tasks. While it was working at 04/07 it stops working today. The only commit to the git repository was related to readme.md (no changes in code).
Strange enough the warnings with issues are being generated during the build but it seems those are ignored. Also I am able to see code & code coderage, only issues were gone.
Analysis of other projects (in .net core 3.1) with the same pipeline are working OK (issues are being reported).
Might be an issue with SonarScanner for MSBuild 5.2.1 (installed via Prepare SonarQube Analysis 1.19.0) or analysis task version 1.22.0…
You may find more details here (logs etc): Issues not being reported for .NET 5 project (issue with SonarScanner for MSBuild 5.2.x?) · Issue #1016 · SonarSource/sonar-scanner-msbuild · GitHub
Hi @jvilimek - first of all, do your projects reference test assemblies (like xunit, nunit etc)?
A change we’ve introduced in 5.2.0 was to Use assembly references to detect Test projects #966 .
If the answer is “yes”, then you can tell the Scanner for .NET that the project is NOT a test project by adding to your {cs,vb} project file:
<PropertyGroup>
<!-- Project is not a test project -->
<SonarQubeTestProject>false</SonarQubeTestProject>
</PropertyGroup>
This is strange, let’s see the logs.
To help more, please give us the verbose output of the commands:
please run SonarScanner.MSBuild.exe begin /k:“MyProject” /d:sonar.verbose=true
as the begin step
please attach the output of the BEGIN and END steps
please also run the MSBuild compilation in verbose mode msbuild /v:d
Thank you!
jvilimek
(Jan Vilimek)
May 4, 2021, 8:48pm
4
Thanks for the reply. As for the project dependencies pls see project.assets.json.zip (67.2 KB) . There should be no xunit/nunit dependencies. I have also tried to add the “SonarQubeTestProject” property to false to the CSPROJ as you suggested but with no luck.
Where should I upload the output of the msbuild? I can store it in onedrive and send share it via a link to your email address perhaps?
Andrei_Epure
(Andrei Epure)
Split this topic
May 6, 2021, 12:39pm
5
jvilimek
(Jan Vilimek)
May 5, 2021, 10:44am
6
Thanks for the hint, but I see in logs, that everything finished OK:
The SonarScanner CLI has finished
Post-processing succeeded.
jvilimek
(Jan Vilimek)
May 5, 2021, 10:45am
7
and for the .net core 3.1 project with the very same pipeline running in the same agent pool (Azure hosted) the analysis report is OK
jvilimek
(Jan Vilimek)
May 5, 2021, 6:01pm
9
Thanks @MPujol for the hint. However we are using SonarCloud Azure DevOps task. I am not aware of a way how we can rollback to previous version
Anyway the working version was the one available on 2021/03/11, that was analysis task version 1.20.0 and SonarScanner for MSBuild 5.1.
I need to highlight, that the version 1.22.0 might have the issue as well, that is the SonarScanner for MSBuild 5.2.0 might have the issue too… sorry for wrong description in the github and here:
jvilimek
(Jan Vilimek)
May 5, 2021, 6:29pm
10
jvilimek
(Jan Vilimek)
May 5, 2021, 6:53pm
11
output:
2021-05-05T18:39:14.3579280Z ##[section]Starting: Prepare SonarQube Analysis
2021-05-05T18:39:14.3585605Z ==============================================================================
2021-05-05T18:39:14.3586172Z Task : Prepare Analysis Configuration
2021-05-05T18:39:14.3586482Z Description : Prepare SonarCloud analysis configuration
2021-05-05T18:39:14.3586926Z Version : 1.19.0
2021-05-05T18:39:14.3587138Z Author : sonarsource
2021-05-05T18:39:14.3587542Z Help : Version: 1.19.0. [More Information](https://sonarcloud.io/documentation/analysis/scan/sonarscanner-for-azure-devops/)
2021-05-05T18:39:14.3588202Z ==============================================================================
2021-05-05T18:39:15.9407951Z SYSTEMVSSCONNECTION exists true
2021-05-05T18:39:16.3076273Z [command]/opt/hostedtoolcache/dotnet/dotnet /home/vsts/work/_tasks/SonarCloudPrepare_14d9cde6-c1da-4d55-aa01-2965cd301255/1.19.0/dotnet-sonar-scanner-msbuild/SonarScanner.MSBuild.dll begin /k:... /o:...
2021-05-05T18:39:16.3898815Z SonarScanner for MSBuild 5.2.1
2021-05-05T18:39:16.3900108Z Using the .NET Core version of the Scanner for MSBuild
2021-05-05T18:39:16.4832496Z Pre-processing started.
2021-05-05T18:39:16.4862684Z Preparing working directories...
2021-05-05T18:39:16.5633783Z 18:39:16.562 18:39:16.548 Loading analysis properties from /home/vsts/work/_tasks/SonarCloudPrepare_14d9cde6-c1da-4d55-aa01-2965cd301255/1.19.0/dotnet-sonar-scanner-msbuild/SonarQube.Analysis.xml
2021-05-05T18:39:16.5635278Z 18:39:16.563 18:39:16.562 sonar.verbose=true was specified - setting the log verbosity to 'Debug'
2021-05-05T18:39:16.5706833Z 18:39:16.57 Updating build integration targets...
2021-05-05T18:39:16.5771570Z 18:39:16.576 Installed SonarQube.Integration.ImportBefore.targets to /home/vsts/.local/share/Microsoft/MSBuild/4.0/Microsoft.Common.targets/ImportBefore
2021-05-05T18:39:16.5776226Z 18:39:16.577 Installed SonarQube.Integration.ImportBefore.targets to /home/vsts/.local/share/Microsoft/MSBuild/10.0/Microsoft.Common.targets/ImportBefore
2021-05-05T18:39:16.5784256Z 18:39:16.578 Installed SonarQube.Integration.ImportBefore.targets to /home/vsts/.local/share/Microsoft/MSBuild/11.0/Microsoft.Common.targets/ImportBefore
2021-05-05T18:39:16.5788889Z 18:39:16.578 Installed SonarQube.Integration.ImportBefore.targets to /home/vsts/.local/share/Microsoft/MSBuild/12.0/Microsoft.Common.targets/ImportBefore
2021-05-05T18:39:16.5794121Z 18:39:16.579 Installed SonarQube.Integration.ImportBefore.targets to /home/vsts/.local/share/Microsoft/MSBuild/14.0/Microsoft.Common.targets/ImportBefore
2021-05-05T18:39:16.5798031Z 18:39:16.579 Installed SonarQube.Integration.ImportBefore.targets to /home/vsts/.local/share/Microsoft/MSBuild/15.0/Microsoft.Common.targets/ImportBefore
2021-05-05T18:39:16.5803044Z 18:39:16.58 Installed SonarQube.Integration.ImportBefore.targets to /home/vsts/.local/share/Microsoft/MSBuild/Current/Microsoft.Common.targets/ImportBefore
2021-05-05T18:39:16.5807856Z 18:39:16.58 Installed SonarQube.Integration.ImportBefore.targets to /home/vsts/Microsoft/MSBuild/15.0/Microsoft.Common.targets/ImportBefore
2021-05-05T18:39:16.5812990Z 18:39:16.581 Installed SonarQube.Integration.ImportBefore.targets to /home/vsts/Microsoft/MSBuild/Current/Microsoft.Common.targets/ImportBefore
2021-05-05T18:39:16.5821185Z 18:39:16.581 Installed SonarQube.Integration.targets to /home/vsts/work/1/.sonarqube/bin/targets
2021-05-05T18:39:16.5840999Z 18:39:16.583 Creating config and output folders...
2021-05-05T18:39:16.5857447Z 18:39:16.585 Creating directory: /home/vsts/work/1/.sonarqube/conf
2021-05-05T18:39:16.5863299Z 18:39:16.585 Creating directory: /home/vsts/work/1/.sonarqube/out
2021-05-05T18:39:16.6201435Z 18:39:16.619 Downloading from https://sonarcloud.io/api/server/version...
2021-05-05T18:39:17.0214567Z 18:39:17.021 SonarCloud detected, skipping license check.
2021-05-05T18:39:17.0298308Z 18:39:17.029 Fetching analysis configuration settings...
2021-05-05T18:39:17.0385044Z 18:39:17.038 Fetching properties for project '...' from https://sonarcloud.io/api/settings/values?component=......
2021-05-05T18:39:17.0439471Z 18:39:17.043 Downloading from https://sonarcloud.io/api/settings/values?component=......
2021-05-05T18:39:17.1152934Z 18:39:17.114 Downloading from https://sonarcloud.io/api/languages/list...
2021-05-05T18:39:17.1384370Z 18:39:17.137 Fetching quality profile for project '...' from https://sonarcloud.io/api/qualityprofiles/search?project=...&organization=......
2021-05-05T18:39:17.1421506Z 18:39:17.141 Downloading from https://sonarcloud.io/api/qualityprofiles/search?project=...&organization=......
2021-05-05T18:39:17.2165778Z 18:39:17.216 Fetching rules for quality profile 'AXhfw98P7EmtJb3rGCHy' from https://sonarcloud.io/api/rules/search?f=repo,name,severity,lang,internalKey,templateKey,params,actives&ps=500&qprofile=AXhfw98P7EmtJb3rGCHy&p=1...
2021-05-05T18:39:17.2191747Z 18:39:17.218 Downloading from https://sonarcloud.io/api/rules/search?f=repo,name,severity,lang,internalKey,templateKey,params,actives&ps=500&qprofile=AXhfw98P7EmtJb3rGCHy&p=1...
2021-05-05T18:39:17.3561175Z 18:39:17.355 Local analyzer cache: /tmp/.sonarqube/resources
2021-05-05T18:39:17.3707853Z 18:39:17.37 Writing Roslyn generated ruleset to /home/vsts/work/1/.sonarqube/conf/Sonar-cs.ruleset...
2021-05-05T18:39:17.3908931Z 18:39:17.39 Writing Roslyn generated ruleset to /home/vsts/work/1/.sonarqube/conf/Sonar-cs-none.ruleset...
2021-05-05T18:39:17.3991021Z 18:39:17.398 Provisioning analyzer assemblies for cs...
2021-05-05T18:39:17.4004318Z 18:39:17.4 Installing required Roslyn analyzers...
2021-05-05T18:39:17.4011097Z 18:39:17.4 Processing plugin: csharp version 8.22.0.31243
2021-05-05T18:39:17.5143302Z 18:39:17.513 Cache miss: plugin files were not found in the local cache
2021-05-05T18:39:17.5158632Z 18:39:17.515 Fetching resource for plugin: csharp, version 8.22.0.31243. Resource: SonarAnalyzer-8.22.0.31243.zip
2021-05-05T18:39:17.5222601Z 18:39:17.521 Downloading SonarAnalyzer-8.22.0.31243.zip from https://sonarcloud.io/static/csharp/SonarAnalyzer-8.22.0.31243.zip to /tmp/.sonarqube/resources/0
2021-05-05T18:39:17.5263225Z 18:39:17.525 Downloading file from https://sonarcloud.io/static/csharp/SonarAnalyzer-8.22.0.31243.zip to /tmp/.sonarqube/resources/0/SonarAnalyzer-8.22.0.31243.zip...
2021-05-05T18:39:17.5780676Z 18:39:17.577 Extracting files to /tmp/.sonarqube/resources/0...
2021-05-05T18:39:17.6140221Z 18:39:17.613 Processing plugin: vbnet version 8.22.0.31243
2021-05-05T18:39:17.6402325Z 18:39:17.639 Cache miss: plugin files were not found in the local cache
2021-05-05T18:39:17.6403725Z 18:39:17.639 Fetching resource for plugin: vbnet, version 8.22.0.31243. Resource: SonarAnalyzer-8.22.0.31243.zip
2021-05-05T18:39:17.6404810Z 18:39:17.639 Downloading SonarAnalyzer-8.22.0.31243.zip from https://sonarcloud.io/static/vbnet/SonarAnalyzer-8.22.0.31243.zip to /tmp/.sonarqube/resources/1
2021-05-05T18:39:17.6405935Z 18:39:17.639 Downloading file from https://sonarcloud.io/static/vbnet/SonarAnalyzer-8.22.0.31243.zip to /tmp/.sonarqube/resources/1/SonarAnalyzer-8.22.0.31243.zip...
2021-05-05T18:39:17.6554334Z 18:39:17.654 Extracting files to /tmp/.sonarqube/resources/1...
2021-05-05T18:39:17.6638892Z 18:39:17.663 Processing plugin: securitycsharpfrontend version 8.9.0.11439
2021-05-05T18:39:17.6651851Z 18:39:17.663 Cache miss: plugin files were not found in the local cache
2021-05-05T18:39:17.6653248Z 18:39:17.663 Fetching resource for plugin: securitycsharpfrontend, version 8.9.0.11439. Resource: SonarAnalyzer.Security-8.9.0.11439.zip
2021-05-05T18:39:17.6654852Z 18:39:17.663 Downloading SonarAnalyzer.Security-8.9.0.11439.zip from https://sonarcloud.io/static/securitycsharpfrontend/SonarAnalyzer.Security-8.9.0.11439.zip to /tmp/.sonarqube/resources/2
2021-05-05T18:39:17.6657569Z 18:39:17.663 Downloading file from https://sonarcloud.io/static/securitycsharpfrontend/SonarAnalyzer.Security-8.9.0.11439.zip to /tmp/.sonarqube/resources/2/SonarAnalyzer.Security-8.9.0.11439.zip...
2021-05-05T18:39:17.6932678Z 18:39:17.683 Extracting files to /tmp/.sonarqube/resources/2...
2021-05-05T18:39:17.7090178Z 18:39:17.708 Writing Roslyn analyzer additional file to /home/vsts/work/1/.sonarqube/conf/cs/SonarLint.xml...
2021-05-05T18:39:17.7334497Z 18:39:17.732 Fetching quality profile for project '...' from https://sonarcloud.io/api/qualityprofiles/search?project=...&organization=......
2021-05-05T18:39:17.7335825Z 18:39:17.732 Downloading from https://sonarcloud.io/api/qualityprofiles/search?project=...&organization=......
2021-05-05T18:39:17.7729035Z 18:39:17.772 Fetching rules for quality profile 'AXhfaXGr7EmtJb3rGAmT' from https://sonarcloud.io/api/rules/search?f=repo,name,severity,lang,internalKey,templateKey,params,actives&ps=500&qprofile=AXhfaXGr7EmtJb3rGAmT&p=1...
2021-05-05T18:39:17.7730171Z 18:39:17.772 Downloading from https://sonarcloud.io/api/rules/search?f=repo,name,severity,lang,internalKey,templateKey,params,actives&ps=500&qprofile=AXhfaXGr7EmtJb3rGAmT&p=1...
2021-05-05T18:39:17.8172681Z 18:39:17.816 Local analyzer cache: /tmp/.sonarqube/resources
2021-05-05T18:39:17.8187908Z 18:39:17.818 Writing Roslyn generated ruleset to /home/vsts/work/1/.sonarqube/conf/Sonar-vbnet.ruleset...
2021-05-05T18:39:17.8205705Z 18:39:17.82 Writing Roslyn generated ruleset to /home/vsts/work/1/.sonarqube/conf/Sonar-vbnet-none.ruleset...
2021-05-05T18:39:17.8219733Z 18:39:17.821 Provisioning analyzer assemblies for vbnet...
2021-05-05T18:39:17.8220252Z 18:39:17.821 Installing required Roslyn analyzers...
2021-05-05T18:39:17.8220695Z 18:39:17.821 Processing plugin: csharp version 8.22.0.31243
2021-05-05T18:39:17.8224398Z 18:39:17.822 Cache hit: using plugin files from /tmp/.sonarqube/resources/0
2021-05-05T18:39:17.8228626Z 18:39:17.822 Processing plugin: vbnet version 8.22.0.31243
2021-05-05T18:39:17.8229087Z 18:39:17.822 Cache hit: using plugin files from /tmp/.sonarqube/resources/1
2021-05-05T18:39:17.8256882Z 18:39:17.825 Writing Roslyn analyzer additional file to /home/vsts/work/1/.sonarqube/conf/vbnet/SonarLint.xml...
2021-05-05T18:39:17.8690269Z 18:39:17.868 Pre-processing succeeded.
2021-05-05T18:39:18.1395544Z ##[section]Finishing: Prepare SonarQube Analysis
jvilimek
(Jan Vilimek)
May 5, 2021, 7:02pm
12
Andrei_Epure:
please attach the output of the BEGIN and END steps
this is the log from SonarCloud analysis step sonar-analysis.txt (1.7 MB)
jvilimek
(Jan Vilimek)
May 5, 2021, 7:09pm
13
Andrei_Epure:
please also run the MSBuild compilation in verbose mode msbuild /v:d
see build-verbose-output.zip (828.3 KB)
Hello @jvilimek
Thanks for the logs.
For the record:
Microsoft (R) Build Engine version 16.9.0+57a23d249
.NET Core 2.181.0
So, we can see
2021-05-05T18:42:53.1125909Z 18:42:53.112 INFO: Found 22 MSBuild C# projects: 5 MAIN projects. 2 TEST projects. 15 with no MAIN nor TEST files.
Is this what you would expect, or is something weird here? Only 5 MAIN projects out of the total of 22?
From the logs:
2021-05-05T18:42:53.2764026Z 18:42:53.273 INFO: Coverage Report Statistics: 21 files, 21 main files, 21 main files with coverage, 0 test files, 0 project excluded files, 0 other language files.
Just to double check - the code coverage was for only 21 files? Does that mean that there are only 21 files analyzed?
I will send you a private message to be able to share the roslyn reports.
jvilimek
(Jan Vilimek)
May 7, 2021, 11:33am
18
that is indeed weird… as we have only 8 projects:
.\src\Ori.AbpBoilerplate.Application\Ori.AbpBoilerplate.Application.csproj
.\src\Ori.AbpBoilerplate.Contract\Ori.AbpBoilerplate.Contract.csproj
.\src\Ori.AbpBoilerplate.Domain\Ori.AbpBoilerplate.Domain.csproj
.\src\Ori.AbpBoilerplate.Infrastructure\Ori.AbpBoilerplate.Infrastructure.csproj
.\src\Ori.AbpBoilerplate.Persistence\Ori.AbpBoilerplate.Persistence.csproj
.\src\Ori.AbpBoilerplate.WebApi\Ori.AbpBoilerplate.WebApi.csproj
.\test\Ori.AbpBoilerplate.Tests\Ori.AbpBoilerplate.Tests.csproj
.\test\Ori.AbpBoilerplate.WebApi.Tests\Ori.AbpBoilerplate.WebApi.Tests.csproj
As for the other question:
Yes. In fact this is a boileplate project. We do have 17 CS files there… Program.cs has [ExcludeFromCodeCoverage]
attrbute and Interfaces does not need to be (I asume) covered by tests, so that gives us 25 files…why only 21 of them is being covered, not sure…
.\src\Ori.AbpBoilerplate.Application\AbpBoilerplateApplicationModule.cs
.\src\Ori.AbpBoilerplate.Application\WeatherForecast\IWeatherForecastsAppService.cs
.\src\Ori.AbpBoilerplate.Application\WeatherForecast\WeatherAutoMapperProfile.cs
.\src\Ori.AbpBoilerplate.Application\WeatherForecast\WeatherForecastsAppService.cs
.\src\Ori.AbpBoilerplate.Contract\AbpBoilerplateContractModule.cs
.\src\Ori.AbpBoilerplate.Contract\WeatherForecast\CreateUpdateWeatherDto.cs
.\src\Ori.AbpBoilerplate.Contract\WeatherForecast\WeatherDto.cs
.\src\Ori.AbpBoilerplate.Domain\AbpBoilerplateDomainModule.cs
.\src\Ori.AbpBoilerplate.Domain\Weather\IWeatherDomainService.cs
.\src\Ori.AbpBoilerplate.Domain\Weather\Weather.cs
.\src\Ori.AbpBoilerplate.Domain\Weather\WeatherDomainService.cs
.\src\Ori.AbpBoilerplate.Persistence\AbpBoilerplatePersistenceModule.cs
.\src\Ori.AbpBoilerplate.Persistence\Fakes\InMemoryRepository.cs
.\src\Ori.AbpBoilerplate.WebApi\Program.cs
.\src\Ori.AbpBoilerplate.WebApi\Startup.cs
.\src\Ori.AbpBoilerplate.WebApi\Configuration\BuildInformation.cs
.\src\Ori.AbpBoilerplate.WebApi\Configuration\ConfigurationSectionNames.cs
.\src\Ori.AbpBoilerplate.WebApi\DependencyInjection\ExceptionHandlingExtension.cs
.\src\Ori.AbpBoilerplate.WebApi\DependencyInjection\MapperExtension.cs
.\src\Ori.AbpBoilerplate.WebApi\DependencyInjection\ServiceCollectionExtensions.cs
.\src\Ori.AbpBoilerplate.WebApi\DependencyInjection\StartupTasksExtensions.cs
.\src\Ori.AbpBoilerplate.WebApi\DependencyInjection\SwaggerUIBuilderExtensions.cs
.\src\Ori.AbpBoilerplate.WebApi\DependencyInjection\TenantSupportExtensions.cs
.\src\Ori.AbpBoilerplate.WebApi\Helpers\SwaggerHelper.cs
.\src\Ori.AbpBoilerplate.WebApi\Modules\AbpBoilerplateApiModule.cs
.\src\Ori.AbpBoilerplate.WebApi\Services\ApiController.cs
.\src\Ori.AbpBoilerplate.WebApi\Services\Controllers\HomeApiController.cs
But we do have 10 test CS files among test projects above the above list
.\test\Ori.AbpBoilerplate.Tests\Application\AbpBoilerplateTestModule.cs
.\test\Ori.AbpBoilerplate.Tests\Application\WeatherAppServiceTests.cs
.\test\Ori.AbpBoilerplate.Tests\Automapper\RegistrationTests.cs
.\test\Ori.AbpBoilerplate.Tests\Infrastructure\TestExtensions.cs
.\test\Ori.AbpBoilerplate.WebApi.Tests\Controllers\RegistrationTests.cs
.\test\Ori.AbpBoilerplate.WebApi.Tests\Controllers\WebApiControllersNameTest.cs
.\test\Ori.AbpBoilerplate.WebApi.Tests\Controllers\Fixtures\ContainerRegistrationFixture.cs
.\test\Ori.AbpBoilerplate.WebApi.Tests\obj\Debug\net5.0\.NETCoreApp,Version=v5.0.AssemblyAttributes.cs
.\test\Ori.AbpBoilerplate.WebApi.Tests\obj\Debug\net5.0\Ori.AbpBoilerplate.WebApi.Tests.AssemblyInfo.cs
.\test\Ori.AbpBoilerplate.WebApi.Tests\Swagger\EndpointsParamsTests.cs
Hi @jvilimek
I’ve sent you a private message. You can access it here (only you can access it).
Maybe you can share with us on the private thread the project or a minimal reproducer, so that we can investigate.
jvilimek
(Jan Vilimek)
June 16, 2021, 4:54pm
22
Ok, after a good few tens of messages with Andrei and his colleague Pawel we have finally managed to find the root cause:
we have pipeline tasks like this:
- task: DotNetCoreCLI@2
displayName: Restore packages
inputs:
command: 'restore'
projects: |
./src/**/*.csproj
./test/**/*.csproj
- task: DotNetCoreCLI@2
displayName: Build
inputs:
command: 'build'
arguments: '-p:Version="..." -p:GeneratePackageOnBuild="false" -p:InformationalVersion="...'
projects: ./src/**/*.csproj
- task: DotNetCoreCLI@2
displayName: Run tests
inputs:
arguments: '--no-restore /p:CollectCoverage=true /p:GeneratePackageOnBuild="false" /p:CoverletOutputFormat=opencover --logger trx /p:RunAnalyzers="false"'
command: 'test'
publishTestResults: false
projects: ./test/**/*.csproj
Notice the "/p:RunAnalyzers="false"
. For .net core 3.1 projects this was working as expected as during the build there were few (duplicate) warnings outputed so this switch off analysis fixed the “double” analysis.
However for .net 5.0 this stopped working. It was probably not related to the tool upgrade, it might have not been working “never ever” for .net 5.0 projects.
2 Likes