Determining if you’re running on the build server with MSBuild – Easy way

Posted by ParadigmShift on Geeks with Blogs See other posts from Geeks with Blogs or by ParadigmShift
Published on Mon, 27 Aug 2012 12:10:47 GMT Indexed on 2012/08/27 21:40 UTC
Read the original article Hit count: 537

Filed under:

When you're customizing MSBuild in building a visual studio project, it often becomes important to determine if the build is running on the build server or your development environment.

This information can change the way you set up path variables and other Conditional tasks.I've found many different answers online.

It seems like they all only worked under certain conditions, so none of them were guaranteed to be consistent.So here's the simplest way I've found that has not failed me yet.

  <PropertyGroup>
    <!-- Determine if the current build is running on the build server -->
    <IsBuildServer>false</IsBuildServer>
    <IsBuildServer Condition="'$(BuildUri)' != ''">true</IsBuildServer>
  </PropertyGroup>
 


Shahzad Qureshi is a Software Engineer and Consultant in Salt Lake City, Utah, USA

His certifications include:

Microsoft Certified System Engineer
3CX Certified Partner
Global Information Assurance Certification – Secure Software Programmer – .NET

He is the owner of Utah VoIP Store at www.UtahVoIPStore.com and SWS Development at www.swsdev.com and publishes windows apps under the name Blue Voice.

© Geeks with Blogs or respective owner