如何告诉 nant 仅在有 cs 文件需要编译时调用 csc?
在我的 NAnt 脚本中,我有一个调用 csc 的编译目标。目前它失败,因为没有指定输入:
<target name="compile">
<csc
target="library"
output="${umbraco.bin.dir}\Mammoth.${project::get-name()}.dll">
<sources>
<include name="project/*.cs" />
</sources>
<references>
</references>
</csc>
</target>
How do I Tell NAnt to notexecute the csc task if there are no CS files?我读到了有关“if”属性的信息,但不确定该使用什么表达式,因为 ${file::exists('*.cs')} 不起作用。
构建脚本是 Umbraco(CMS)项目的模板,项目中可能有也可能没有 .cs 源文件。理想情况下,我不希望开发人员需要记住修改 NAnt 脚本以在将 .cs 文件添加到项目时包含编译任务(或在删除所有 .cs 文件时排除它)。
In my NAnt script I have a compile target that calls csc. Currently it fails because no inputs are specified:
<target name="compile">
<csc
target="library"
output="${umbraco.bin.dir}\Mammoth.${project::get-name()}.dll">
<sources>
<include name="project/*.cs" />
</sources>
<references>
</references>
</csc>
</target>
How do I tell NAnt to not execute the csc task if there are no CS files? I read about the 'if' attribute but am unsure what expression to use with it, as ${file::exists('*.cs')} does not work.
The build script is a template for Umbraco (a CMS) projects and may or may not ever have .cs source files in the project. Ideally I would like to not have developers need to remember to modify the NAnt script to include the compile task when .cs files are added to the project (or exclude it when all .cs files are removed).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是关于 NAnt 文件集。
是文件集类型。在 NAnt 中处理这些文件集通常很尴尬。由于没有函数fileset::is-empty
我们需要明确地检查这一点:我同意这有点麻烦,但我不知道有什么替代方法。好吧,您可以在文件集上使用属性
failonempty
,但随后您需要处理异常。更新:就在昨天,我发现了一个替代方案:如果您不介意使用 NAntContrib 有一个函数
fileset::has -文件
。这是代码:This is about NAnt filesets.
<sources>
is of type fileset. Handling those filesets often is awkward in NAnt. Since there is no functionfileset::is-empty
we need to check this explicitly:I agree that this is somewhat cumbersome but I'm not aware of an alternative. Well, you could use attribute
failonempty
on the fileset but then you would need to handle the exception.Update: Just yesterday I found an alternative: If you don't mind using NAntContrib there is a function
fileset::has-files
. This is the code: