Current situation: 10 csproj files mention <TreatWarningsAsErrors>true</TreatWarningsAsErrors> .
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.
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.
I leave 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 .
Versions:
SonarCloud is the cloud-hosted version
TeamCity plugin: Sonar runner Allows configuring and running SonarQube analysis on the TeamCity server, version 2020.1-11
TeamCity tool: SonarScanner for MSBuild v 5.6.0.48455-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?