如何防止不良的项目参考? [英] How can I prevent bad project references?
问题描述
我们正在将带有TFS的C#项目用作源代码控制和CI构建.
We are using C# projects with TFS as source control and for the CI builds.
我不断发现其他开发人员在应使用我们的/Libs
文件夹(我们保留第三方组装的文件夹)时,错误地引用了/Bin
目录中的组装
I keep finding that other developers are referencing assemblies from /Bin
directories incorrectly when they should be using our /Libs
folder (where we keep 3rd party assemblies)
作为解决方案构建或CI构建(我们也使用powershell)的一部分,如果有人这样做,我该怎么做才能检查构建并使其失败?
What can I do as part of the solution build or CI build (we do also use powershell) to check and fail the build if anyone does this?
推荐答案
Add a custom activity to your build process template. The activity's pseudo code should look like:
- 在编译阶段之前执行.
- 循环包含所有以* proj结尾的文件扩展名的新变更集.
- 对于所有* proj文件,请在其内容中搜索包含
\Bin
的HintPath
元素. - 如果结果> 0,则退出并出错生成,列出策略失败的项目.
- Execute before the compilation phase.
- Loop all new changesets containing file extensions ending with *proj.
- For all *proj files, search their contents for
HintPath
elements containing\Bin
. - If results > 0, exit build with error, listing the policy failing projects.
要完成该解决方案,还可以考虑强制执行 VS客户端的自定义签入策略 .
To complete the solution also consider enforcing a custom check-in policy for the VS clients.
这篇关于如何防止不良的项目参考?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!