我有一个 nant 脚本,它... 1. 获取光盘文件的内容 2. 将该内容分配给 nant 属性 3. 然后使用 -v 调用 sqlcmd 并传入包含光盘文件内容的属性 4.在 sql 脚本中,文件的内容应该由存储过程使用。
问题是当文件内容包含空格时,nant 构建会因“无效参数”问题而停止
有人知道解决这个问题的方法吗?
nant 脚本的顶部是...
<?xml version="1.0"?>
<!-- the main name of this project -->
<project name="Hops" default="all">
<!-- BuildHistory -->
<property name="buildHistoryContents" value="" />
<xmlpeek xpath="/" file="BuildNotes.xml" property="buildHistoryContents"></xmlpeek>
<!-- <echo message="${buildHistoryContents}" /> -->
<!-- ***************** -->
<target name="ExecSql">
<echo message="running sql script : ${SqlBuildScriptsDir}${sqlBuildFileName}" />
<exec program="${SqlCmd}" commandline="-S ${SqlServerInstanceName} -E -d HBus -i ${SqlBuildScriptsDir}${sqlBuildFileName} -v vSchemaVersion=${buildHistoryContents} " />
</target>
sql 脚本包含以下行...
exec lsp_SchemaVersionUpsert '1.4', N'$(vSchemaVersion)'
有效的光盘文件内容是...
<BuildNotes>
<Note>
<buildVer>HasNotSpace</buildVer>
</Note>
</BuildNotes>
无效的光盘文件内容是...
<BuildNotes>
<Note>
<buildVer>Has Space</buildVer>
</Note>
</BuildNotes>
所有这些的用途是将 xml 构建注释传递给 db 模式的表记录版本构建历史。
有谁知道另一种方法或知道一种方法?
下一部分,在 Phillip Keeley 正确解决第一部分(空间问题)之后添加,我简化了原始任务以简化问题。
还有一个引用属性问题;xml 引用的属性导致 nant 构建失败并出现“无效参数”。
例如,这将导致 nant 阻塞,但删除 dt 属性将使 nant 构建成功...
<BuildNotes>
<Note>
<buildVer>1.4</buildVer>
<dateStarted>09/24/2009 11:25:42</dateStarted>
<Item dt="20091008" >SpacesAndNoQuotedAttribute</Item>
</Note>
</BuildNotes>
有任何想法吗 ... ?