Question

I have an nant build where I am trying to call a powershell cmdlet like below:

<exec program="powershell.exe" commandline='.\Download.ps1 ${dir}' />

This works fine as long as there dir path doesn't contain white spaces and throws below error:

A positional parameter cannot be found that accepts argument .....

I tried below to fix this but that doesn't work.

<exec program="powershell.exe" commandline='.\Download.ps1 "${dir}"' />
Was it helpful?

Solution 2

Got is fixed by modifying the exec task as:

<exec program="powershell.exe" commandline=".\Download.ps1 '${dir}'" />

OTHER TIPS

Try this instead:

<exec program="powershell.exe">
    <arg value=".\Download.ps1"/>
    <arg value="${dir}"/>
</exec>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top