内容文件丢失时如何使MSBuild失败 [英] How to fail an MSBuild when content files are missing
问题描述
我注意到,当缺少内容文件时,我们的巡航控制服务器不会使构建失败.
I've noticed that our cruise control server does not fail the build when content files are missing.
当javascript/图形文件等丢失时,我想使构建失败.如何使用从svn中提取的文件来验证项目文件?
I'd like to fail the build when javascript / graphics files etc are missing. How can I go about validating the project file with the files pulled from svn?
推荐答案
您可以创建一个目标来检查以确保所有Content文件都位于磁盘上,如果不是这种情况,则会引发错误.这是一个目标
You can create a target to check to make sure that all Content files are physically located on disk and raise an error if this is not the case. Here is such a target
<Target Name="ValidateContentFiles">
<Error Condition="!Exists(%(Content.FullPath))"
Text="Missing Content file [%(Content.FullPath)]"/>
</Target>
通过将其添加到Project元素的InitialTargets属性中,可以确保每次都执行此目标.例如
You can make sure that this target is executed everytime by adding it to the InitialTargets attribute on the Project element. For example
<Project InitialTargets="ValidateContentFiles"
ToolsVersion="3.5" DefaultTargets="Build"
xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
易卜拉欣·哈希米说
我的书:在Microsoft Build Engine内部:使用MSBuild和团队基础建设
这篇关于内容文件丢失时如何使MSBuild失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!