ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Bailey, Darragh" <>
Subject RE: Apply argument wrapping with msiexec
Date Wed, 10 Nov 2010 17:48:01 GMT

> -----Original Message-----
> From: Stefan Bodewig [] 
> Sent: 10 November 2010 16:14
> To:
> Subject: Re: Apply argument wrapping with msiexec
> On 2010-11-09, Bailey, Darragh wrote:
> > I have the following target in a project
> >   <target name="extract-msi" depends="init" if="" >
> >     <mkdir dir="${build.dir}/extract/msi" />
> >     <apply executable="msiexec" failonerror="true" >
> >       <arg value="/a" /> <!-- administrative install -->
> >       <srcfile/>
> >       <arg value='TARGETDIR="${build.dir}\extract\msi"' />
> >       <fileset dir="${src.dir}" >
> >         <include name="**/*.msi" />
> >       </fileset>
> >     </apply>
> >   </target>
> > Basically the problem appears to be with the TARGETDIR line. If I
> > remove that line, then the msiexec command will run just fine, but
> > will extract the msi contents to the wrong location (C:\).
> Do you get some sort of error message?

Msiexec, oh so usefully pops up the usage dialog box whenever you get a command line option
wrong :/. Basically no idea what it saw as the inputs, other than it didn't like them.

> > It seems that despite the claims in the console: The ' characters
> > around the executable and arguments are not part of the command.
> No, they are not. 8-)

Guess I should have done some investigation. Sticking the ' around that command line arguments
basically reproduced error if I ran the entire command line manually. Some more testing with
it shows that <arg value="TARGETDIR=C:\test" /> works fine. The problems start if there
is a space in the path.

None of the following work for me:
<arg value="TARGETDIR=C:\Documents and Settings\Test" />
<arg value="TARGETDIR=&quot;C:\Documents and Settings\Test&quot;" />
<arg value="TARGETDIR='C:\Documents and Settings\Test'" />
<arg value="TARGETDIR=\'C:\Documents and Settings\Test\'" />
<arg value='TARGETDIR=C:\Documents and Settings\Test' />
<arg value='TARGETDIR="C:\Documents and Settings\Test"' />
<arg value='TARGETDIR=\"C:\Documents and Settings\Test\"' />
<arg value='TARGETDIR=&quot;C:\Documents and Settings\Test&quot;' />

These do though
<arg value="TARGETDIR=C:\Test" />
<arg value="TARGETDIR=&quot;C:\Test&quot;" />
<arg value='TARGETDIR=C:\Test' />
<arg value='TARGETDIR=&quot;C:\Test&quot;' />

I didn't bother testing the remainder, since that was enough to confirm that the space is
the main problem. What ever way that is getting passed through, the behaviour is different
to when passing everything through as one long command line directly to cmd.

> Ant uses an exec() method that passes the parameters as an array of
> strings and these strings are not quoted.  In fact quoting may even
> cause problems - you may try 
>       <arg value='TARGETDIR=${build.dir}\extract\msi' />
> i.e. without the double quotes.  It may or may not help.

It doesn't.

Basically, it seems that once there is a space in the path specified by the TARGETDIR property,
it breaks. Works fine when wrapping the path in quotes directly on the command.

At this point, I don't see any straight forward solution. If it becomes a necessity I'll probably
have to script something in order to get it to work. Like perhaps echo'ing each line out to
a batch script and then executing that.

Darragh Bailey

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message