To quote or not to quote – that's the question

Since I’m using NAnt to build my solution I include all steps needed to get a build up and running. So recently I added the fantastic WSPBuilder to my lastest build file:

<target name="build.wsp" description="Packages the WSP file">
<exec program="${dir_buildtools}\wspbuilder\wspbuilder.exe">
<arg value="-BuildCAS false"/>
<arg value="-DeploymentTraget BIN" />
<arg value="-TraceLevel verbose"/>
</exec>
<move todir="${build.dir}" overwrite="true">
<fileset>
<include name="**.wsp"/>
</fileset>
</move>
</target>

But this didn’t work out as expected, for some strange reason the command line args added with the arg element where just ignored!

OK, let’s examine what is going on here. If you look closely, you’ll notice that the actuall command being executed looks like: wspbuider.exe "-BuildCAS false" "-DeploymentTraget BIN" "-TraceLevel verbose". But apparently wspbuilder doesn’t like the arguments enclosed in quotes, because the whole arg is being interpreted as just a single string. So parsing for -BuildCAS fails, because the actual string is longer (when using space for tokenizing!).

So what next? This does the trick:

<target name="build.wsp" description="Packages the WSP file">
<exec program="${dir_buildtools}\wspbuilder\wspbuilder.exe" commandline="-BuildCAS false -DeploymentTraget BIN" >
</exec>
<move todir="${build.dir}" overwrite="true">
<fileset>
<include name="**.wsp"/>
</fileset>
</move>
</target>

In this case I supply the complete commandline arguments

Leave a Comment.