How to treat warnings as errors in Azure DevOps Pipeline VSBuild task?

779 Views Asked by At

A request came in to treat all warnings as errors in our build pipelines. The expectation is that it will report all as errors and will stop the pipeline from getting the green check mark. After a bit of research, I thought I could just apply a simple parameter to the MSBuild call, but it doesn't appear to work. (TreatWarningsAsErrors="true")

The warning is being reported as a warning and the build succeeds instead of failing.

 - task: VSBuild@1
      displayName: 'Building Solution'
      inputs:
          solution: '$(SOLUTION_NAME)'
          vsVersion: '15.0'
          msbuildArgs: '/p:TreatWarningsAsErrors="true" /p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:PackageLocation=”$(build.artifactstagingdirectory)\\”'
          platform: 'any cpu'
          configuration: $(CONFIGURATION)
          clean: true

How do I fail a pipeline if there is a warning?

0

There are 0 best solutions below