Search code examples
powershelltfstfs-2015

How to activate "treat warning as error" for specific build definitions?


I would like to make my main branch TFS build definitions to treat warnings as errors so that the build fails when the projects are not error free. Since I do not want to activate "treat error as warning" in all project as a default, my first idea was to add a powershell script to my main build definition that substitues false with true in the line <TreatWarningsAsErrors>...</TreatWarningsAsErrors> in all csproj files it finds (something along the line of this). Is there any better/straighter way via some option as part of the build definition settings?


Solution

  • In the build definition specify /p:TreatWarningsAsErrors=True in the MSBuild argument field.

    This will override any setting from the csproj files.