{"id":553,"date":"2004-01-05T11:43:23","date_gmt":"2004-01-05T15:43:23","guid":{"rendered":"http:\/\/wordpress.cephas.net\/?p=553"},"modified":"2004-01-05T11:43:23","modified_gmt":"2004-01-05T15:43:23","slug":"nant-build-file-tips","status":"publish","type":"post","link":"https:\/\/cephas.net\/blog\/2004\/01\/05\/nant-build-file-tips\/","title":{"rendered":"NAnt build file tips"},"content":{"rendered":"<p>I found the documentation for NAnt to be lacking in build file examples, especially examples that deal with more than one task or include.  If you&#8217;re completely new to NAnt, I&#8217;d suggest reading the <a href=\"http:\/\/www.ondotnet.com\/pub\/a\/dotnet\/2003\/01\/27\/nant.html\">article<\/a> that <a href=\"http:\/\/mcmanus.typepad.com\/\">Jeffrey McManus<\/a> wrote for ondotnet. If not, read on.  <\/p>\n<p>One of the first things you&#8217;ll notice when reading examples on any site is that most of them are explicit in regard to the fileset to be compiled. You&#8217;ll see this:<br \/>\n<code><br \/>\n&lt;csc target=\"library\" output=\"company.dll\"&gt;<br \/>\n&nbsp;&lt;sources&gt;<br \/>\n&nbsp;&nbsp;&lt;includes name=\"src\\com\\company\\packagea\\ClassA.cs\"\/&gt;<br \/>\n&nbsp;&nbsp;&lt;includes name=\"src\\com\\company\\packagea\\ClassB.cs\"\/&gt;<br \/>\n&nbsp;&nbsp;&lt;includes name=\"src\\com\\company\\packageb\\ClassC.cs\"\/&gt;<br \/>\n....<br \/>\n<\/code><br \/>\ninstead of something like this:<br \/>\n<code><br \/>\n&lt;csc target=\"library\" output=\"company.dll\"&gt;<br \/>\n&nbsp;&lt;sources&gt;<br \/>\n&nbsp;&nbsp;&lt;includes name=\"src\\com\\company\\packagea\\*.cs\"\/&gt;<br \/>\n&nbsp;&nbsp;&lt;includes name=\"src\\com\\company\\packageb\\*.cs\"\/&gt;<br \/>\n....<br \/>\n<\/code><br \/>\nOf course, this means that you have to manually add in each namespace, which can be tedious and error prone.  NAnt provides a shorthand: **, which means we can reduce the above to this:<br \/>\n<code><br \/>\n&lt;csc target=\"library\" output=\"company.dll\"&gt;<br \/>\n&nbsp;&lt;sources&gt;<br \/>\n&nbsp;&nbsp;&lt;includes name=\"src\\com\\company\\**\\*.cs\"\/&gt;<br \/>\n....<br \/>\n<\/code><br \/>\nIf you don&#8217;t want a particular file included in the list (say for instance all the files in &#8216;packageb&#8217;), you can use the &lt;excludes&gt; tag like so:<br \/>\n<code><br \/>\n&lt;csc target=\"library\" output=\"company.dll\"&gt;<br \/>\n&nbsp;&lt;sources&gt;<br \/>\n&nbsp;&nbsp;&lt;includes name=\"src\\com\\company\\**\\*.cs\"\/&gt;<br \/>\n&nbsp;&nbsp;&lt;excludes name=\"src\\com\\company\\packageb\\*.cs\"\/&gt;<br \/>\n<\/code><br \/>\nThat&#8217;s all I had off the top of my head.  There are a couple new features in <a href=\"http:\/\/nant.sourceforge.net\/releasenotes.html\">release .84<\/a> that might be worth taking a look at: <a href=\"http:\/\/nant.sourceforge.net\/help\/tasks\/xmlpeek.html\">xmlpeek<\/a> (which allows you to extract text from an xml file like say for instance the web.config), <a href=\"http:\/\/nant.sourceforge.net\/help\/tasks\/xmlpoke.html\">xmlpoke<\/a> (which allows you to replace text in an xml file&#8230;) and <a href=\"http:\/\/nant.sourceforge.net\/help\/tasks\/servicecontroller.html\">servicecontroller<\/a> (which allows you to stop\/start\/restart Windows Services).<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I found the documentation for NAnt to be lacking in build file examples, especially examples that deal with more than one task or include. If you&#8217;re completely new to NAnt, I&#8217;d suggest reading the article that Jeffrey McManus wrote for ondotnet. If not, read on. One of the first things you&#8217;ll notice when reading examples &hellip; <a href=\"https:\/\/cephas.net\/blog\/2004\/01\/05\/nant-build-file-tips\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">NAnt build file tips<\/span> <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[17,2],"tags":[],"_links":{"self":[{"href":"https:\/\/cephas.net\/blog\/wp-json\/wp\/v2\/posts\/553"}],"collection":[{"href":"https:\/\/cephas.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/cephas.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/cephas.net\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/cephas.net\/blog\/wp-json\/wp\/v2\/comments?post=553"}],"version-history":[{"count":0,"href":"https:\/\/cephas.net\/blog\/wp-json\/wp\/v2\/posts\/553\/revisions"}],"wp:attachment":[{"href":"https:\/\/cephas.net\/blog\/wp-json\/wp\/v2\/media?parent=553"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/cephas.net\/blog\/wp-json\/wp\/v2\/categories?post=553"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/cephas.net\/blog\/wp-json\/wp\/v2\/tags?post=553"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}