Search code examples
nant

Nant script - How to check if it runs on a server or on a dev machine?


I have a Nant build script. It may be executed on either dev machine or build server.

I want to skip a build step on a dev machine but still run it on a server.

How can I check if the script runs on a server or on a dev machine?


Solution

  • It's all about adding something special to the build server. I can think of two options from the top of my head:

    • Environment variable: just make sure build server has a specific environment variable and check its existence in your NAnt script

    • Special environment.include file: make sure build server has a special environment.include file in the root of the C drive, for example, and define build server specific NAnt properties there, like <property name="is.build.server" value="true" />.

      You can include this kind of file like this:

      <include buildfile="\Environment.include" if="${file::exists('\Environment.include')}"/>