In the csproj file of a project I have conditionals for TreatWarningsAsErrors.
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<TreatWarningsAsErrors>False</TreatWarningsAsErrors>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
<TreatWarningsAsErrors>True</TreatWarningsAsErrors>
</PropertyGroup>
On my computer running
dotnet build solution.sln --Configuration Debug
vs
dotnet build solution.sln --Configuration Release
produces the different results with success and failure as expected.
On our on-prem azure devops server however, even though the log clearly states "--Configuration Release" they show the problems as Warnings. Not failures as expected.
What can be wrong here?
The build log excerpts:
Starting: dotnet build
==============================================================================
Task : .NET Core
Description : Build, test, package, or publish a dotnet application, or run a custom dotnet command
Version : 2.181.0
Author : Microsoft Corporation
Help : https://learn.microsoft.com/azure/devops/pipelines/tasks/build/dotnet-core-cli
==============================================================================
C:\Windows\system32\chcp.com 65001
Active code page: 65001
Info: .NET Core SDK/runtime 2.2 and 3.0 are now End of Life(EOL) and have been removed from all hosted agents. If you're using these SDK/runtimes on hosted agents, kindly upgrade to newer versions which are not EOL, or else use UseDotNet task to install the required version.
F:\A\BUILDEDUI12C-B01\_work\_tool\dotnet\dotnet.exe build F:\A\BUILDEDUI12C-B01\_work\754\s\Modules\ScheduleMaker\Backend\ScheduleMaker.sln "-dl:CentralLogger,\"F:\A\BUILDEDUI12C-B01\_work\_tasks\DotNetCoreCLI_5541a522-603c-47ad-91fc-a4b1d163081b\2.181.0\dotnet-build-helpers\Microsoft.TeamFoundation.DistributedTask.MSBuild.Logger.dll\"*ForwardingLogger,\"F:\A\BUILDEDUI12C-B01\_work\_tasks\DotNetCoreCLI_5541a522-603c-47ad-91fc-a4b1d163081b\2.181.0\dotnet-build-helpers\Microsoft.TeamFoundation.DistributedTask.MSBuild.Logger.dll\"" --configuration Release -p:CustomBeforeMicrosoftCommonTargets=F:\A\BUILDEDUI12C-B01\_work\754\s\WE.CI.Tools.Build\Utilities\Education.SonarQube.ImportBefore.targets -p:SQProjectKey=WE.Education.ScheduleMaker
Microsoft (R) Build Engine version 17.1.1+a02f73656 for .NET
[warning]Modules\ScheduleMaker\Backend\Service\WE.Education.ScheduleMaker.Business\Services\ActivityService.cs(61,13): Warning S125: Remove this commented out code.
Edit: From the diagnostics log i can see that the condition works, it says it changes the variable to True.
2022-04-14T07:06:33.6901214Z Property reassignment: $(TreatWarningsAsErrors)="True" (previous value: "false") at F:\A\BUILDEDUI12A-B01\_work\650\s\Modules\ScheduleMaker\Backend\Service\WE.Education.ScheduleMaker.Business\WE.Education.ScheduleMaker.Business.csproj (19,5)
But It dosen't act as it's true.