我似乎無法讓NAnt在遇到錯誤時放棄構建。這裏有很多sqlcmd.exe處決的一個:NAnt,sqlcmd.exe和錯誤代碼
<property name="test" value=""/>
<exec program="sqlcmd.exe" resultproperty="test" failonerror="true"
basedir="${sqlcmd.dir}" commandline="${commandline.script}" verbose="true">
<arg value="${filename}" />
<arg value="-v databaseName="${Database.Name}"" />
</exec>
<echo message="Result: ${test}"/>
當我打到這一步,我結束了一個錯誤,由於(在這種情況下)缺少逗號。下面是輸出:
[exec] Starting 'C:\...\sqlcmd.exe (-E -S (local) -e -d "Core"
-i "C:\...\Associations.sql" -v databaseName="Core")'
in 'C:\...\Scripts'
[exec] <snip - lots of SQL>
[exec] Msg 102, Level 15, State 1, Server <snip>, Line 7
[exec] Incorrect syntax near 'CreatedDate'.
[exec] Msg 319, Level 15, State 1, Server <snip>, Line 11
[exec] Incorrect syntax near the keyword 'with'. If this
statement is a common table expression, an xmlnamespaces
clause or a change tracking context clause, the previous
statement must be terminated with a semicolon.
[echo] Result: 0
非常討厭的錯誤,然而sqlcmd.exe出現在返回代碼設置爲0
任何想法,以確保我的腳本中止時,我缺少一個逗號?
非常好,那就是訣竅。非常感謝! – ladenedge 2010-09-07 17:54:42