Getting Environment variables in NAnt - No Fluff Just Stuff

Getting Environment variables in NAnt

Posted by: Paul Duvall on June 13, 2006

NAnt contains an impressive set of functions that can be used to get anything from the current working directory to determining whether a file exists to getting environment variables. The syntax is a bit unusual for a build script and the NAnt documentation is sparse on examples. The example below demonstrates the use of the NAnt Environment functions to get the environment variable values for the working machine.

<property name="ncover.console.exe"
 value="${environment::get-variable('NCOVER_HOME')}\NCover.Console.exe" />
<property name="nunit.console.exe"
value="${environment::get-variable('NUNIT_HOME')}\bin\nunit-console.exe" />
Paul Duvall

About Paul Duvall

Paul M. Duvall is the CEO of Stelligent, a consulting firm that helps clients create production-ready software every day. He has worked in virtually every role on software projects: developer, project manager, architect and tester. He's been a featured speaker at many leading software conferences. He is the principal author of Continuous Integration: Improving Software Quality and Reducing Risk (Addison-Wesley, 2007; Jolt 2008 Award Winner). He contributed to the UML 2 Toolkit (Wiley, 2003), authors a series for IBM developerWorks called Automation for the people and authored a chapter in the No Fluff Just Stuff Anthology: The 2007 Edition (Pragmatic Programmers, 2007). He is passionate about automating software development and release processes. He actively blogs on IntegrateButton.com

Why Attend the NFJS Tour?

  • » Cutting-Edge Technologies
  • » Agile Practices
  • » Peer Exchange

Current Topics:

  • Languages on the JVM: Scala, Groovy, Clojure
  • Enterprise Java
  • Core Java, Java 8
  • Agility
  • Testing: Geb, Spock, Easyb
  • REST
  • NoSQL: MongoDB, Cassandra
  • Hadoop
  • Spring 4
  • Cloud
  • Automation Tools: Gradle, Git, Jenkins, Sonar
  • HTML5, CSS3, AngularJS, jQuery, Usability
  • Mobile Apps - iPhone and Android
  • More...
Learn More »