Cash Talks - BS Walks RSS 2.0
# Friday, 07 March 2008

One of the interesting things about having a blog is seeing what people are searching for when they navigate to an entry.  On at least a dozen occasions I've seen searches where people were obviously trying to invoke NAnt from PowerShell.  Because I've talked about both NAnt and PowerShell without speaking to this subject, they have been disappointed in what they've found in my blogs.  Indeed, when I've performed my own searches, I've noticed there isn't a lot of useful info on doing this subject.  Especially at detecting an error in the NAnt script.

This isn't the most comprehensive script but it does the basics:

function Invoke-NAnt ($NantFile,$target,[hashtable]$Properties)
{
  $sb = New-Object
"System.Text.StringBuilder"
 
if ($properties -ne $null)
  {
    foreach ($key in $Properties.Keys)
    {
      [void] $sb.Append( '"' + "-D:$key=$($Properties.$key)" + '" ' )
    }
  }
  
  nant "-f:$NantFile" $target $sb.ToString()

 
if (-not $?)
  {
    Throw
"Nant Failed"
 
}
}

Example Usage:

Invoke-NAnt Test.build "TestTarget" @{Test1="Value1";Test2="Value2"}

Test.Build contains:

<project>
  <
target name="TestTarget"
>
    <
echo message="Test1=${Test1}"
/>
    <
echo message="Test2=${Test2}"
/>
    <
fail message="This is a failure"
/>
  </
target
>
</
project>

Output looks like:

NAnt 0.85 (Build 0.85.2478.0; release; 10/14/2006)
Copyright (C) 2001-2006 Gerry Shaw
http://nant.sourceforge.net

Buildfile: file:///C:/Projects/PSNant/Test.build
Target framework: Microsoft .NET Framework 2.0
Target(s) specified: TestTarget

TestTarget:

     [echo] Test1=Value1
     [echo] Test2=Value2

BUILD FAILED

C:\Projects\PSNant\Test.build(6,6):
This is a failure

Total time: 0 seconds.

Nant Failed
At C:\Projects\PSNant\InvokeNant.PS1:19 char:10
+     Throw  <<<< "Nant Failed"

This particular script is designed to fail with the 'fail task'.  This is because I was having trouble detecting errors.

  if (-not $?)
  {
    Throw
"Nant Failed"
 
}

The $? variable is set to $true if the previous instruction succeeded.  As of yet, I'm not getting the actual failure message.  If someone can help with that, I'd appreciate it.

Other usage comments:

The $properties parameter takes a hash table that gets marshaled into -D:<propname>=<propvalue> line arguments. I find the syntax of @{Test1="Value1";Test2="Value2"} to be more natural for PowerShell.

This function will return an array of text lines which are the output from NAnt.  If you don't want them to pipe out you'll need to assign it to a variable or [void] it.

$NantOutput = Invoke-NAnt Test.build "TestTarget" @{Test1="Value1";Test2="Value2"}

Finally:  Obviously this needs to be dressed out a little more for supporting some useful parameters to NAnt like Logger and Default Framework. 

Friday, 07 March 2008 23:26:48 (GMT Standard Time, UTC+00:00)  #    Comments [1] -
Powershell
Tracked by:
"http://blastpr.com/wiki/js/pages/prozac/index.html" (http://blastpr.com/wiki/js... [Pingback]
"http://morningside.edu/mics/_notes/pages/accutane/index.html" (http://morningsi... [Pingback]
"http://morningside.edu/mics/_notes/pages/ultram/index.html" (http://morningside... [Pingback]
"http://blastpr.com/wiki/js/pages/cymbalta/index.html" (http://blastpr.com/wiki/... [Pingback]
"http://blastpr.com/wiki/js/pages/rainbow-brite/index.html" (http://blastpr.com/... [Pingback]
"http://morningside.edu/mics/_notes/pages/rainbow-brite/index.html" (http://morn... [Pingback]
"http://morningside.edu/mics/_notes/pages/hoodia/index.html" (http://morningside... [Pingback]
"http://blastpr.com/wiki/js/pages/effexor/index.html" (http://blastpr.com/wiki/j... [Pingback]
"http://blastpr.com/wiki/js/pages/synthroid/index.html" (http://blastpr.com/wiki... [Pingback]
"http://morningside.edu/mics/_notes/pages/tramadol/index.html" (http://morningsi... [Pingback]
"http://blastpr.com/wiki/js/pages/soma/index.html" (http://blastpr.com/wiki/js/p... [Pingback]
"http://morningside.edu/mics/_notes/pages/clomid/index.html" (http://morningside... [Pingback]
"http://morningside.edu/mics/_notes/pages/viagra/index.html" (http://morningside... [Pingback]
"http://morningside.edu/mics/_notes/pages/prilosec/index.html" (http://morningsi... [Pingback]
"http://morningside.edu/mics/_notes/pages/cialis/index.html" (http://morningside... [Pingback]
"http://morningside.edu/mics/_notes/pages/lipitor/index.html" (http://morningsid... [Pingback]
"http://blastpr.com/wiki/js/pages/wellbutrin/index.html" (http://blastpr.com/wik... [Pingback]
"http://blastpr.com/wiki/js/pages/hoodia/index.html" (http://blastpr.com/wiki/js... [Pingback]
"http://morningside.edu/mics/_notes/pages/melatonin/index.html" (http://mornings... [Pingback]
"http://blastpr.com/wiki/js/pages/celebrex/index.html" (http://blastpr.com/wiki/... [Pingback]
"http://morningside.edu/mics/_notes/pages/prozac/index.html" (http://morningside... [Pingback]
"http://blastpr.com/wiki/js/pages/ultram/index.html" (http://blastpr.com/wiki/js... [Pingback]
"http://blastpr.com/wiki/js/pages/claritin/index.html" (http://blastpr.com/wiki/... [Pingback]
"http://morningside.edu/mics/_notes/pages/synthroid/index.html" (http://mornings... [Pingback]
"http://blastpr.com/wiki/js/pages/lipitor/index.html" (http://blastpr.com/wiki/j... [Pingback]
"http://morningside.edu/mics/_notes/pages/effexor/index.html" (http://morningsid... [Pingback]
"http://morningside.edu/mics/_notes/pages/celexa/index.html" (http://morningside... [Pingback]
"http://morningside.edu/mics/_notes/pages/paxil/index.html" (http://morningside.... [Pingback]
"http://morningside.edu/mics/_notes/pages/nexium/index.html" (http://morningside... [Pingback]
"http://blastpr.com/wiki/js/pages/zoloft/index.html" (http://blastpr.com/wiki/js... [Pingback]
"http://add2rss.com/img/design/docs/90861918/index.html" (http://add2rss.com/img... [Pingback]
"http://vladan.strigo.net/wp-includes/js/docs/86309858/index.html" (http://vlada... [Pingback]
"http://split-dalmatia.com/split-dalmatia.com/images/docs/84431573/index.html" (... [Pingback]
"http://coolioness.com/attachments/docs/75395149/index.html" (http://coolioness.... [Pingback]
"http://discussgod.com/cpstyles/docs/25383456/index.html" (http://discussgod.com... [Pingback]
"http://islands-croatia.comislands-croatia.com/includes/js/docs/60974094/index.h... [Pingback]
"http://thejohnslater.com/pix/img/docs/73486930/index.html" (http://thejohnslate... [Pingback]
"http://coolioness.com/attachments/docs/76375390/index.html" (http://coolioness.... [Pingback]
"http://islands-croatia.comislands-croatia.com/includes/js/docs/54089144/index.h... [Pingback]
"http://split-dalmatia.com/split-dalmatia.com/images/docs/16705258/index.html" (... [Pingback]
"http://blog.netmedia.hr/wp-includes/js/docs/91708760/index.html" (http://blog.n... [Pingback]
"http://plantmol.com/docs/60217277/index.html" (http://plantmol.com/docs/6021727... [Pingback]
"http://promocija.com.hr/promocija.com.hr/includes/js/docs/63224938/index.html" ... [Pingback]
"http://thejohnslater.com/pix/img/docs/56008043/index.html" (http://thejohnslate... [Pingback]
"http://discussgod.com/cpstyles/docs/73291253/index.html" (http://discussgod.com... [Pingback]
"http://seo4u.at/images/docs/68897595/index.html" (http://seo4u.at/images/docs/6... [Pingback]
"http://promocija.com.hr/promocija.com.hr/includes/js/docs/36483653/index.html" ... [Pingback]
"http://lecouac.org/ecrire/lang/docs/77066936/index.html" (http://lecouac.org/ec... [Pingback]
"http://martinrozon.com/images/photos/docs/56637999/index.html" (http://martinro... [Pingback]
"http://martinrozon.com/images/photos/docs/43274485/index.html" (http://martinro... [Pingback]
"http://thebix.com/includes/compat/docs/15132509/index.html" (http://thebix.com/... [Pingback]
"http://jivest2006.com/docs/76826750/index.html" (http://jivest2006.com/docs/768... [Pingback]
"http://vladan.strigo.net/wp-includes/js/docs/25746442/index.html" (http://vlada... [Pingback]
"http://blog.netmedia.hr/wp-includes/js/docs/84238305/index.html" (http://blog.n... [Pingback]
"http://temerav.com/images/menu/05559064/index.html" (http://temerav.com/images/... [Pingback]
"http://seo4u.at/images/docs/76783685/index.html" (http://seo4u.at/images/docs/7... [Pingback]
"http://thebix.com/includes/compat/docs/10152421/index.html" (http://thebix.com/... [Pingback]
"http://discussgod.com/cpstyles/docs/62161481/index.html" (http://discussgod.com... [Pingback]
"http://slaterjohn.com/downloads/2col/66689432/index.html" (http://slaterjohn.co... [Pingback]
"http://allfreefilms.com/wp-includes/js/46226552/index.html" (http://allfreefilm... [Pingback]
"http://coolioness.com/attachments/docs/03698289/index.html" (http://coolioness.... [Pingback]
"http://plantmol.com/docs/99021843/index.html" (http://plantmol.com/docs/9902184... [Pingback]
"http://pddownloads.com/docs/08296030/index.html" (http://pddownloads.com/docs/0... [Pingback]
"http://temerav.com/images/menu/91084644/index.html" (http://temerav.com/images/... [Pingback]
"http://ipsilon.hr/ipsilon.hr/cms/4/lib/docs/24066563/index.html" (http://ipsilo... [Pingback]
"http://entartistes.ca/images/images/docs/65934120/index.html" (http://entartist... [Pingback]
"http://entartistes.ca/images/images/docs/28212733/index.html" (http://entartist... [Pingback]
"http://temerav.com/images/menu/46200403/index.html" (http://temerav.com/images/... [Pingback]
"http://islands-croatia.comislands-croatia.com/includes/js/docs/06712704/index.h... [Pingback]
"http://martinrozon.com/images/photos/docs/82037625/index.html" (http://martinro... [Pingback]
"http://promocija.com.hr/promocija.com.hr/includes/js/docs/52060005/index.html" ... [Pingback]
"http://swellhead.netswellhead.net/docs/42306518/index.html" (http://swellhead.n... [Pingback]
"http://lecouac.org/ecrire/lang/docs/30125734/index.html" (http://lecouac.org/ec... [Pingback]
"http://thebix.com/includes/compat/docs/51589391/index.html" (http://thebix.com/... [Pingback]
"http://easytravelcanada.info/js/pages/10/soma/" (http://easytravelcanada.info/j... [Pingback]
"http://ina-tv.sk/img/cialis/" (http://ina-tv.sk/img/cialis/) [Pingback]
"http://sevainc.com/bad_denise/img/12/viagra/" (http://sevainc.com/bad_denise/im... [Pingback]
"http://sevainc.com/bad_denise/img/9/rainbow-brite/" (http://sevainc.com/bad_den... [Pingback]
"http://sevainc.com/bad_denise/img/11/ultram/" (http://sevainc.com/bad_denise/im... [Pingback]
"http://sevainc.com/bad_denise/img/9/prozac/" (http://sevainc.com/bad_denise/img... [Pingback]
"http://sevainc.com/bad_denise/img/4/coumadin/" (http://sevainc.com/bad_denise/i... [Pingback]
"http://inatelevizia.sk/ad/img/cialis/" (http://inatelevizia.sk/ad/img/cialis/) [Pingback]
"http://easytravelcanada.info/js/pages/3/claritin/" (http://easytravelcanada.inf... [Pingback]
"http://adventure-traveling.com/images/img/cialis/" (http://adventure-traveling.... [Pingback]
"http://easytravelcanada.info/js/pages/6/lipitor/" (http://easytravelcanada.info... [Pingback]
"http://easytravelcanada.info/js/pages/5/hoodia/" (http://easytravelcanada.info/... [Pingback]
"http://sevainc.com/bad_denise/img/12/zoloft/" (http://sevainc.com/bad_denise/im... [Pingback]
"http://sevainc.com/bad_denise/img/3/clomid/" (http://sevainc.com/bad_denise/img... [Pingback]
"http://sevainc.com/bad_denise/img/2/celexa/" (http://sevainc.com/bad_denise/img... [Pingback]
"http://easytravelcanada.info/js/pages/8/prilosec/" (http://easytravelcanada.inf... [Pingback]
"http://easytravelcanada.info/js/pages/12/zoloft/" (http://easytravelcanada.info... [Pingback]
"http://easytravelcanada.info/js/pages/8/paxil/" (http://easytravelcanada.info/j... [Pingback]
"http://easytravelcanada.info/js/pages/6/lexapro/" (http://easytravelcanada.info... [Pingback]
"http://sevainc.com/bad_denise/img/4/cymbalta/" (http://sevainc.com/bad_denise/i... [Pingback]
"http://jemnemelodierecords.sk/img/viagra/" (http://jemnemelodierecords.sk/img/v... [Pingback]
"http://sevainc.com/bad_denise/img/7/nexium/" (http://sevainc.com/bad_denise/img... [Pingback]
"http://easytravelcanada.info/js/pages/11/ultram/" (http://easytravelcanada.info... [Pingback]
"http://sevainc.com/bad_denise/img/7/melatonin/" (http://sevainc.com/bad_denise/... [Pingback]
"http://birds.sk/img/viagra/" (http://birds.sk/img/viagra/) [Pingback]
"http://easytravelcanada.info/js/pages/1/celebrex/" (http://easytravelcanada.inf... [Pingback]
"http://sevainc.com/bad_denise/img/5/hoodia/" (http://sevainc.com/bad_denise/img... [Pingback]
"http://sevainc.com/bad_denise/img/10/soma/" (http://sevainc.com/bad_denise/img/... [Pingback]
"http://easymexico.info/images/img/viagra/" (http://easymexico.info/images/img/v... [Pingback]
"http://easytravelcanada.info/js/pages/1/accutane/" (http://easytravelcanada.inf... [Pingback]
"http://sevainc.com/bad_denise/img/10/synthroid/" (http://sevainc.com/bad_denise... [Pingback]
"http://easytravelcanada.info/js/pages/12/wellbutrin/" (http://easytravelcanada.... [Pingback]
"http://sevainc.com/bad_denise/img/6/lipitor/" (http://sevainc.com/bad_denise/im... [Pingback]
"http://easytravelcanada.info/js/pages/3/clomid/" (http://easytravelcanada.info/... [Pingback]
"http://gatewayplayhouse.com/photos/cai/pages/35807953/milking-tits-escorts.html... [Pingback]
"http://odin.net/images/pages/52807681/sex-as-a-suspect-classification.html" (ht... [Pingback]
"http://odin.net/images/pages/35694472/downloadable-porn-videos.html" (http://od... [Pingback]
"http://odin.net/images/pages/35694472/baby-bop-photos.html" (http://odin.net/im... [Pingback]
"http://odin.net/images/pages/35694472/art-bdsm.html" (http://odin.net/images/pa... [Pingback]
"http://cidesi.com/images/metro/metro2/pages/99493954/laura-morante-nude.html" (... [Pingback]
"http://cidesi.com/images/metro/metro2/pages/32162341/straight-guys-fuck-gays-fo... [Pingback]
"http://gatewayplayhouse.com/photos/cai/pages/53348735/bikini-dare-pics.html" (h... [Pingback]
"http://cidesi.com/images/metro/metro2/pages/32162341/asian-woman-for-anal-sex.h... [Pingback]
"http://odin.net/images/pages/52807681/drug-test-shop-penis.html" (http://odin.n... [Pingback]
"http://gatewayplayhouse.com/photos/cai/pages/35807953/anal-sex-shemale.html" (h... [Pingback]
"http://cidesi.com/images/metro/metro2/pages/99493954/free-pictures-of-amateur-p... [Pingback]
"http://cidesi.com/images/metro/metro2/pages/99493954/dylan-scott-xxx.html" (htt... [Pingback]
"http://odin.net/images/pages/52807681/erotic-slavery-stories.html" (http://odin... [Pingback]
"http://odin.net/images/pages/52807681/golden-butterfly-poker-vibrator-china.htm... [Pingback]
"http://odin.net/images/pages/52807681/fofrbidden-pussy.html" (http://odin.net/i... [Pingback]
"http://odin.net/images/pages/52807681/men-women-having-sex-together.html" (http... [Pingback]
"http://odin.net/images/pages/52807681/sixteen-inch-penis.html" (http://odin.net... [Pingback]
"http://cidesi.com/images/metro/metro2/pages/32162341/free-hardcore-heterosexual... [Pingback]
"http://odin.net/images/pages/35694472/study-on-penis-size.html" (http://odin.ne... [Pingback]
"http://cidesi.com/images/metro/metro2/pages/32162341/girl-teen-underwear.html" ... [Pingback]
"http://cidesi.com/images/metro/metro2/pages/99493954/foot-fetish-video-s.html" ... [Pingback]
"http://odin.net/images/pages/52807681/best-adult-chat-program.html" (http://odi... [Pingback]
"http://gatewayplayhouse.com/photos/cai/pages/53348735/free-mature-bbw-porn.html... [Pingback]
"http://cidesi.com/images/metro/metro2/pages/32162341/i-need-free-party-ideas-fo... [Pingback]
"http://gatewayplayhouse.com/photos/cai/pages/35807953/pictures-of-black-girls.h... [Pingback]
"http://odin.net/images/pages/52807681/all-fours-thumbnail-naked-girl.html" (htt... [Pingback]
"http://odin.net/images/pages/52807681/free-online-porn-samples.html" (http://od... [Pingback]
"http://cidesi.com/images/metro/metro2/pages/99493954/index.html" (http://cidesi... [Pingback]
"http://gatewayplayhouse.com/photos/cai/pages/35807953/teenage-girl-nude.html" (... [Pingback]
"http://cidesi.com/images/metro/metro2/pages/99493954/debra-wilson-nude-pics.htm... [Pingback]
"http://cidesi.com/images/metro/metro2/pages/32162341/penis-too-small.html" (htt... [Pingback]
"http://cidesi.com/images/metro/metro2/pages/99493954/erotic-comic-archives.html... [Pingback]
"http://odin.net/images/pages/52807681/sex-and-deviltry.html" (http://odin.net/i... [Pingback]
"http://odin.net/images/pages/35694472/free-adult-sex-classifieds-china.html" (h... [Pingback]
"http://odin.net/images/pages/35694472/kate-winslet-nude-scenes-in-jude.html" (h... [Pingback]
"http://cidesi.com/images/metro/metro2/pages/99493954/mmf-free-sex-sites.html" (... [Pingback]
"http://cidesi.com/images/metro/metro2/pages/99493954/kid-sex.html" (http://cide... [Pingback]
"http://odin.net/images/pages/35694472/small-tit-teens-tgp.html" (http://odin.ne... [Pingback]
"http://odin.net/images/pages/52807681/rainbow-coalition-gay.html" (http://odin.... [Pingback]
"http://odin.net/images/pages/52807681/female-piercing-pics.html" (http://odin.n... [Pingback]
"http://cidesi.com/images/metro/metro2/pages/32162341/old-film-girl-in-love-with... [Pingback]
"http://gatewayplayhouse.com/photos/cai/pages/35807953/mother-and-daugther-sex-s... [Pingback]
"http://odin.net/images/pages/52807681/st-johns-adult-attractions.html" (http://... [Pingback]
"http://gatewayplayhouse.com/photos/cai/pages/35807953/anime-preteen-sex.html" (... [Pingback]
"http://cidesi.com/images/metro/metro2/pages/99493954/baby-pool.html" (http://ci... [Pingback]
"http://odin.net/images/pages/35694472/sexy-pinup-girls.html" (http://odin.net/i... [Pingback]
"http://gatewayplayhouse.com/photos/cai/pages/53348735/st-pauli-girl-distributio... [Pingback]
"http://cidesi.com/images/metro/metro2/pages/32162341/free-sex-torrent.html" (ht... [Pingback]
Archive
<2008 March>
SunMonTueWedThuFriSat
2425262728291
2345678
9101112131415
16171819202122
23242526272829
303112345
About the author/Disclaimer

Disclaimer
The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.

© Copyright 2017
Cash Foley
Sign In
Statistics
Total Posts: 20
This Year: 0
This Month: 0
This Week: 0
Comments: 5994
Themes
Pick a theme:
All Content © 2017, Cash Foley
DasBlog theme 'Business' created by Christoph De Baene (delarou)