缺少内容文件时如何使 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?
推荐答案
您可以创建一个目标来检查以确保所有内容文件都物理位于磁盘上,如果不是这种情况,则会引发错误.这里有这样一个目标
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">
赛义德·易卜拉欣·哈希米
Sayed Ibrahim Hashimi
我的书:微软构建引擎内部:使用 MSBuild 和团队基础构建
这篇关于缺少内容文件时如何使 MSBuild 失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!