Note that there are some explanatory texts on larger screens.

plurals
  1. PONant, SqlCmd -v switch and spaces in nant property fails build with invalid argument
    text
    copied!<p>I have a nant script that ... 1. takes the content of disc-file 2. assigns that content to a nant property 3. and then calls sqlcmd with a -v passing in that property containg the content of the disc file 4. inside the sql script the contents of the file should be used by a stored proc. </p> <p>The problem is that when the content of the file contains a space the nant build stops with a "Invalid argument" issue</p> <p>Anone know a way around this ?</p> <p>The top part of the nant script is ...</p> <pre><code>&lt;?xml version="1.0"?&gt; &lt;!-- the main name of this project --&gt; &lt;project name="Hops" default="all"&gt; &lt;!-- BuildHistory --&gt; &lt;property name="buildHistoryContents" value="" /&gt; &lt;xmlpeek xpath="/" file="BuildNotes.xml" property="buildHistoryContents"&gt;&lt;/xmlpeek&gt; &lt;!-- &lt;echo message="${buildHistoryContents}" /&gt; --&gt; &lt;!-- ***************** --&gt; &lt;target name="ExecSql"&gt; &lt;echo message="running sql script : ${SqlBuildScriptsDir}${sqlBuildFileName}" /&gt; &lt;exec program="${SqlCmd}" commandline="-S ${SqlServerInstanceName} -E -d HBus -i ${SqlBuildScriptsDir}${sqlBuildFileName} -v vSchemaVersion=${buildHistoryContents} " /&gt; &lt;/target&gt; </code></pre> <p>The sql script contains the line ...</p> <pre><code>exec lsp_SchemaVersionUpsert '1.4', N'$(vSchemaVersion)' </code></pre> <p>A disc file content that works is ...</p> <pre><code>&lt;BuildNotes&gt; &lt;Note&gt; &lt;buildVer&gt;HasNotSpace&lt;/buildVer&gt; &lt;/Note&gt; &lt;/BuildNotes&gt; </code></pre> <p>A disc file content that does not works is ...</p> <pre><code>&lt;BuildNotes&gt; &lt;Note&gt; &lt;buildVer&gt;Has Space&lt;/buildVer&gt; &lt;/Note&gt; &lt;/BuildNotes&gt; </code></pre> <p>The use of all this is pass xml build comments to a table logging version build history for the db schema.</p> <p>Does anyone know an alternate method or know a way through this ?</p> <p>The next part, added after Phillip Keeley correcty solved first part (the <em>SPACE Problem</em>) I simplified the original task to simplify the question.</p> <p>There is also a <em>Quoted Attribute Problem</em> ; xml quoted attributes cause the nant build to fail with "Invalid Argument".</p> <p>eg this will cause nant to choke but removing the dt attribute will enable the nant build to succeed ...</p> <pre><code>&lt;BuildNotes&gt; &lt;Note&gt; &lt;buildVer&gt;1.4&lt;/buildVer&gt; &lt;dateStarted&gt;09/24/2009 11:25:42&lt;/dateStarted&gt; &lt;Item dt="20091008" &gt;SpacesAndNoQuotedAttribute&lt;/Item&gt; &lt;/Note&gt; &lt;/BuildNotes&gt; </code></pre> <p>Any ideas ... ?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload