我m getting a problem in a Nant Build i
跑了,
有一部分我需要执行一个文件然后删除它,但只有文件存在时,
但是剧本仍然失败
****相关的脚本部分:****
<do>
<property name="lessfolder.parent" value="${directory::get-parent-directory(lessfile)}" />
<property name="lessfolder.parent.parent" value="${directory::get-parent-directory(lessfolder.parent)}" />
<property name="lessfolder.parent.parent.parent" value="${directory::get-parent-directory(lessfolder.parent.parent)}" />
<property name="cssfile" value="${path::get-file-name-without-extension(lessfile)}" />
<property name="sabatfiletest" value="${core.publish}\less\LessSaCompile.bat" />
<echo file="${sabatfiletest}" append="true">
call ${less} "${lessfile}" > "${lessfolder.parent.parent.parent}\SA_${cssfile}.css"
</echo>
</do>
</foreach>
<exec program="${core.publish}\less\LessCompile.bat">
</exec>
<sleep seconds="4" />
<exec program="${core.publish}\less\LessSubDomainCompile.bat">
</exec>
<sleep seconds="4" />
<exec program="${core.publish}\less\LessSaCompile.bat" if="${file::exists(sabatfiletest)}">
</exec>
<sleep seconds="4" />
<delete file="${core.publish}\less\LessCompile.bat" />
<delete file="${core.publish}\less\LessSubDomainCompile.bat" />
<delete file="${core.publish}\less\LessSaCompile.bat" if="${file::exists(sabatfiletest)}" />
</target>
****和错误我得到:****
Build Error: NAnt.Core.BuildException
Property evaluation failed. Expression: ${file::exists(sabatfiletest)} ^^^^^^^^^^^^^
in D:\Projects\Integration\Scripts\NAnt\iFOREX.Framework.BuildTFS.xml line: 725 col: 6
at NAnt.Core.PropertyDictionary.EvaluateEmbeddedExpressions(String input, Location location, Hashtable state, Stack visiting)
at NAnt.Core.PropertyDictionary.ExpandProperties(String input, Location location)
at NAnt.Core.Element.AttributeConfigurator.InitializeAttribute(PropertyInfo propertyInfo)
at NAnt.Core.Element.AttributeConfigurator.Initialize()
at NAnt.Core.Element.InitializeXml(XmlNode elementNode, PropertyDictionary properties, FrameworkInfo framework)
at NAnt.Core.Element.Initialize(XmlNode elementNode, PropertyDictionary properties, FrameworkInfo framework)
at NAnt.Core.Element.Initialize(XmlNode elementNode)
at NAnt.Core.Project.CreateTask(XmlNode taskNode, Target target)
at NAnt.Core.Target.Execute()
at NAnt.Core.Project.Execute(String targetName, Boolean forceDependencies)
at NAnt.Core.Project.Execute()
at NAnt.Core.Project.Run()
答案 0 :(得分:0)
如果尚未定义扩展中涉及的属性,通常会看到此错误。从发布的脚本中,看起来参数是在<foreach>
任务中定义的。
你还没有发布<foreach>
任务的开头或导致它的原因,但我猜测在某些情况下它永远不会进入循环。如果是这种情况,则在循环后属性将保持未定义,并将导致此错误。
简单的解决方案是在循环之前将属性定义为默认值。鉴于它在file::exists
中使用,将其定义为空白应该没问题:
<property name="sabatfiletest" value="" />