Hello all,
I am trying to setup a nAnt task to run a batch file with 4 parameters. First 2 parameters are folder path, so it required to be wrapped with double quote. Here's my build file
<?xml version="1.0"?>
<project name="Proejct" default="dbsetup" >
<description>nAnt script</description>
<property name="project.SQLBinFolder" value='"C:\Program Files\Microsoft SQL Server\90\Tools\Binn\"' />
<property name="project.SQLDataFolder" value='"C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\DATA\"' />
<property name="project.DBServerName" value="JJADEJA-VISTA-P\SQLEXPRESS" />
<property name="project.DatabaseName" value="dbMain" />
<target name="test">
<echo message="..\Database\RunDBSQL.bat ${project.SQLBinFolder} ${project.SQLDataFolder} ${project.DBServerName} ${project.DatabaseName}" />
</target>
<target name="dbsetup" description="Setup database script">
<exec program="..\Database\RunDBSQL.bat" >
<arg value="${project.SQLBinFolder}" />
<arg value="${project.SQLDataFolder}" />
<arg value="${project.DBServerName}" />
<arg value="${project.DatabaseName}" />
</exec>
</target>
</project>
my test target outputs
..\Database\RunDBSQL.bat "C:\Program Files\Microsoft SQL Server\90\Tools\Binn\" "C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\DATA\dbCIMA" JJADEJA-VISTA-P\SQLEXPRESS dbCIMA
which is works fine from command line.
When I run dbsetup target, it gives me following error.
dbsetup:
[exec] Files\Microsoft was unexpected at this time.
BUILD FAILED - 0 non-fatal error(s), 1 warning(s)
c:\Projects\CIMA\Trunk\Solution file\CIMA.build(15,6):
External Program Failed: c:\Projects\CIMA\Trunk\Database\RunDBSQL.bat (return co
de was 255)
Total time: 0.1 seconds.
My RunDBSQL.bat
SET SQLBinFolder="%1"
SET SQLDataFolder="%2"
SET DBServerName=%3
SET DatabaseName=%4
SET PATH="%1%"
cls
echo.
echo *****************************
echo * Database build and update *
echo *****************************
echo.
echo SQLCmd Exe Path : %SQLBinFolder%
echo SQL Data Folder Path : %SQLDataFolder%
echo Database server: %DBServerName%
echo Database name : %DatabaseName%
echo.
I trying wrapping my variables and property in all kind of combination of wrapping / escaping, but no luck. Anyone has got any suggestion or idea, please let me know.
Thanks In advance, Jay