Search code examples
.netpowershellcontinuous-integrationnant

Powershell cmdlet params in nant


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}"' />

Solution

  • Got is fixed by modifying the exec task as:

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