Current situation: 10 csproj files mention
Cf. Configuration of WarningsAsErrors for .NET build SonarCloud overrides this setting to enable the warning collection
I want to extract common MSBuild properties to a Directory.Build.props file, one of those properties is TreatWarningsAsErrors.
Now when I run the analysis SonarCloud is no longer able to overrule this setting? And it fails my analysis step in CI.
- ALM used : GitHub
- CI system used : TeamCity
- Scanner command used when applicable : SonarCloud
- Languages of the repository: .NET C#
I’m not sure I understand what you’re trying to achieve. What’s the point of having
<TreatWarningsAsErrors>true</TreatWarningsAsErrors> when you want it to be overridden by SonarCloud analysis?
Also please share what version of Scanner for .NET, or Azure DevOps extensioni are you using.
TreatWarningsAsErrors on so regular C#/.NET warnings have to be fixed in Visual Studio otherwise the build does not complete.
SonarCloud invents/injects other warnings during analysis and specifically disables
TreatWarningsAsErrors so as not to fail the build => OK in continuous integration .
SonarCloud is the cloud-hosted version
Sonar runner Allows configuring and running SonarQube analysis on the TeamCity server, version 2020.1-11
TeamCity tool: SonarScanner for MSBuild v 22.214.171.124455-net46
Just to clarify: are you asking whether setting
<TreatWarningsAsErrors>true</TreatWarningsAsErrors> will cause a problem with the CI analysis, or stating that it is a problem?
The SonarScanner for .NET sets the property dynamically during the build, so it should override the static value set in the project. Is this not the behaviour you are seeing?
Nevermind this topic, I was using the
Maybe this property should also be overriden in OverrideRoslynCodeAnalysisProperties in SonarQube.Integration.targets .
FYI the scanner does correctly override the
TreatWarningsAsErrors MSBuild property, but not the
We’ll create a ticket to look at it.
Update: ticket is S4Net #1603
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.