.net 当有cs文件要编译时,如何告诉nant只调用csc?
在NAnt脚本中,我有一个调用csc的编译目标。由于未指定任何输入,因此当前它失败:.net 当有cs文件要编译时,如何告诉nant只调用csc?,.net,build-automation,nant,.net,Build Automation,Nant,在NAnt脚本中,我有一个调用csc的编译目标。由于未指定任何输入,因此当前它失败: <target name="compile"> <csc target="library" output="${umbraco.bin.dir}\Mammoth.${project::get-name()}.dll"> <sources> <include name="project/*.cs" />
<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>
如果没有CS文件,我如何告诉NAnt不要执行csc任务?我读过关于'if'属性的内容,但不确定使用什么表达式,因为${file::exists('*.cs')}不起作用
构建脚本是Umbraco(CMS)项目的模板,项目中可能有也可能没有.cs源文件。理想情况下,我不希望开发人员需要记住在将.cs文件添加到项目中时修改NAnt脚本以包含编译任务(或者在删除所有.cs文件时将其排除)。这是关于<代码>属于文件集类型。在NAnt中,处理这些文件集通常很麻烦。由于没有函数fileset::is empty
,我们需要明确检查:
<fileset id="sourcefiles">
<include name="project/*.cs" />
</fileset>
<property
name="sourcefiles.count"
value="0" />
<foreach item="File" property="filename">
<in>
<items refid="sourcefiles" />
</in>
<do>
<property
name="sourcefiles.count"
value="${int::parse(sourcefiles.count) + 1}" />
</do>
</foreach>
<if test="${int::parse(sourcefiles.count) > 0}">
<csc
target="library"
output="${umbraco.bin.dir}\Mammoth.${project::get-name()}.dll">
<sources refid="sourcefiles" />
<references>
</references>
</csc>
</if>
哇!谢谢你的回答中有很多我不知道南特能做的:)它对我有用:)谢谢你的回答。如果有错误导致jpg图像出现在文件夹中,我只尝试在testsuite运行后移动和压缩jpg屏幕截图。
<fileset id="sourcefiles">
<include name="project/*.cs" />
</fileset>
<if test="${fileset::has-files('sourcefiles')}">
<csc
target="library"
output="${umbraco.bin.dir}\Mammoth.${project::get-name()}.dll">
<sources refid="sourcefiles" />
<references>
</references>
</csc>
</if>