I have a build pipeline in AzureDevOps that builds a .NET Core 5 solution using the AzureDevOps Task '.NET Core' -> Build
The solution has a Directory.Build.props file that has the setting:
<PropertyGroup>
<TreatWarningsAsErrors>True</TreatWarningsAsErrors>
</PropertyGroup>
That means that any warning will be propagated as error.
After some time a collegae encountered a local build fail (it is a warning CS8603: Possible null reference return -> which become an error due to our setting) but the build pipeline succeeds with the same code base (commit).
The build agent has the following .NET Core SDK versions: 5.0.402, 5.0.408.
The local dev machine uses VS2022 with .NET Core SDK versions: 2.1.300, 2.1.402, 2.1.526, 2.1.700, 3.1.420, 5.0.401, 5.0.408 and 6.0.301
Outside VS2022, a local dotnet build has the same error.
What could be the issue here ?
Well... somehow I didn't notice the warning was indeed remote, but it was not a CSC compiler warning, but a Sonar warning.
When using the MSBuildTreatWarningsAsErrors like this:
<PropertyGroup>
<TreatWarningsAsErrors>True</TreatWarningsAsErrors>
<MSBuildTreatWarningsAsErrors>true</MSBuildTreatWarningsAsErrors>
</PropertyGroup>
we see the Sonar warnings as errors also in Azure DevOps.
(solution based on this SO topic: Azure Devops dotnet build don't respect configuration )
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.