Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7607385
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T00:38:57+00:00 2026-05-31T00:38:57+00:00

I have been automating all my builds through PSake and finding it really useful

  • 0

I have been automating all my builds through PSake and finding it really useful to get my TeamCity build more powerful.

One thing I would like to introduce is a step to make sure all projects in a solution have warnings as errors set to true. It isn’t that often that I spot a project not having this but I am also now working on a legacy codebase where it is not so prevalent.

I was hoping to be able to create a quick check that the setting was on.
I am guessing there would be a way by checking for the correct text (

<TreatWarningsAsErrors>true</TreatWarningsAsErrors>

) in the .*proj files but I hoped there might be a cleaner or more effective way.

Any ideas?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T00:38:58+00:00Added an answer on May 31, 2026 at 12:38 am

    I don’t understand what’s wrong with probing the .*proj files, so I’ll assume you wouldn’t like to just search for a whole string literal.

    Project files are XML based, so here’s a Linq to XML code snippet that will let you find what you’re looking for:

    void VerifyTreatWarningsAsErrorsIsOn( string projFilename )
    {
        XNamespace xmlns = "http://schemas.microsoft.com/developer/msbuild/2003";
        var twaeList = XDocument.Load( projFilename ).Descendants( xmlns + "TreatWarningsAsErrors" ).ToList();
    
        if ( twaeList.Count() > 0 )
        {
            var falseValues = twaeList.Where( x => x.Value == "true" );
            if ( falseValues.Count() > 0 )
            {
                    // Not good..
            }
        }
        else
        {
            // None exist.. not good either..
        }
    }
    

    One thing that’s a bit off in your problem domain is that you might have project files, which have the flag switched on for one configuration (e.g. debug), but you won’t be able to tell if it even exists in other configurations.

    So actually, you can extend the above code and traverse all configurations and look for the flag per configuration. Moreover – if the configuration doesn’t exist, or is set to ‘false’ – you can just manipulate the XML document and insert / fix all these problems on the fly.

    HTH.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been tasked with automating our build process with msbuild. We have about
I have IE8 installed on my computer and have been working on automating some
I have been learning Xcode 4.2 for a bit now and still can't get
I have been developing for iPhone from last 1-2 months and all the time
We have been looking at automatically logging all unexpected client errors to our bug
Been working on a personal add-in for VS 2008 and have been researching automation
We use Perl for GUI test automation. It has been very successful. We have
Have been looking at the MVC storefront and see that IQueryable is returned from
Have been studying the file system related classes of Adobe AIR 1.5, but so
Have been struggling with Javascript closure for a while trying to wrap brain around

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.