我如何检查文件是否存在,如果不存在,则终止版本?

我如何检查文件是否存在,如果不存在,则终止版本?

问题描述:

如何停止构建,并在文件不存在时通知用户?我知道如果文件存在,我可以使用可用的任务来设置属性,但是我不确定如何停止构建并回显某些内容.

How can I stop a build, and notify the user if a file does not exist? I know I can use the available task to set a property if a file exists, but I'm not sure how I would stop a build and echo something.

如果可能的话,我想坚持核心任务.

I would like to stick with core tasks if possible.

您可以使用失败任务来满足您所有失败的需求.该页面上的最后一个示例实际上就是您所需要的

You can use the fail task for all your failing needs. The last example on that page is actually pretty much what you need

<fail message="Files are missing.">
    <condition>
        <not>
            <resourcecount count="2">
                <fileset id="fs" dir="." includes="one.txt,two.txt"/>
            </resourcecount>
        </not>
    </condition>
</fail>