NAnt best practices [closed]
Asked Answered
N

1

8

I have here 300 lines long NAnt file and it is quite a messy. I am wondering if there is a any style guide for writing NAnt scripts and what are the best practices for doing so.

Any tips?

Nonna answered 18/9, 2008 at 16:29 Comment(0)
D
5

I'm not aware of any published style guide, but I can certainly share my experience. You can use many of the same techniques used in other programming environments, such as making the code modular and splitting it across multiple files. In the environment that I have set up, each project is laid out like so: "[ProjectName]\Common" contains a common build file that is linked to nearly all of my projects. I also have a set of common subversion targets stored in a file there. The "Common" subdirectory is actually an svn:external, so it's automatically kept in sync across multiple projects. In the Common.build file, there are lots of environmental properties, plus some reusable filesets, some reusable targets, and a "StartUp" target that is used by each projects "StartUp" target.

"[ProjectName]\Project.build" contains all of that projects specific properties and filesets, some of which override the settings from Common.build. This file also contains a "StartUp" target which sets up some runtime settings like assembly version information and any dependent paths. It also executes the "Startup" target from Common.build. This file includes the Common.build file.

"[ProjectName][AssemblyName].build" contains all of the settings and targets specific to an individual assembly. This file includes the Project.build, which in turn includes the Common.build.

This hierarchy works well in our situation, which has us building a trunk version and several branch versions of a product on a continuous integration server. As it stands now, the only differences between the scripts for building the trunk version and any one of the branches are only a handful of lines.

Defoe answered 18/9, 2008 at 18:28 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.