1  /  1  页   1 跳转 查看:789

Custom MSBuild Tasks

Custom MSBuild Tasks

Posted by Hartmut Wilms  From/InfoQ

Since version 2.0 Microsoft has integrated MSBuild, a build system, into the .NET Framework that is fully compatible with Visual Studio projects. Bart de Smet shows how to extend MSBuild via custom tasks.

Although the set of built-in MSBuild tasks covers most of a developer's needs, some areas - especially deployment, integration of version control systems, configuration of servers and IIS web sites as well as ActiveDirectory tasks are left out. The MSBuild Community Tasks Project and the SDC Tasks Library, which are both freely available, provide many MSBuild tasks that address most of the issues in these areas. If something's still missing, you have to (and can) help yourself.

Bart de Smet shows how to create and debug custom MSBuild tasks. Whereas his first article serves as an introduction to creating custom tasks, his second article is written in a cookbook-style and focuses on debugging. According to Bart the development of a custom task is divided into 8 steps:
Step 1 - Create a Class Library project
Step 2 - Import references
Step 3 - Implement the task skeleton
Step 4 - Task parameterization
Step 5 - Implementing functionality
Step 6 - Setting up debugging
Step 7 - Set a breakpoint and run
Step 8 - Advanced debugging
Debugging is essentially configured in the custom MSBuild task's project properties: The project's start action must be set to the MSBuild executable (which should match the MSBuild assemblies referenced by the project) and the start options have to include the path to a test MSBuild project file.

The MSBuild Team blog provides further information and help, and the article "MSBuild - What It Does and What You Can Expect in the Future" by Dan Moseley and Xin Yan is a good summary of MSBuild's features, concepts, new file format features in .NET 3.5, and future directions.

 感谢原创者的辛勤劳动,希望对您有所帮助,转载请注明原出处。
 您可能对 [Visual Studio.NET] 的这些文章也感兴趣:

Windows Workflow Foundation 之旅---(2)扩展Hello程序
使用FileSystemWatcher监控网络路径(含源码下载)
.NET Framework3.0答疑
.NET快捷键集合
XNA Game Studio 2已发布
刷新页面后保留密码框的值
Boo Lang Studio简介
.net内常用的几种文件类型
Convert HTML tables to a DataSet
.net程序中资源文件的保护办法探讨
 

回复: Custom MSBuild Tasks

自定义MSBuild任务

译/张逸

自从微软在.NET Framework 2.0版本中集成了MSBuild 构建系统,.NET框架就与Visual Studio项目完全兼容了。Bart de Smet演示了如何通过自定义任务来扩展MSBuild。

虽然一系列内置的MSBuild任务能够满足开发者的大多数需求,然而对于某些领域——特别是部署、与版本控制系统的集成、服务器配置、IIS网站以及ActiveDirectory任务,内置的MSBuild任务仍然是鞭长莫及。为了解决这些领域中的大部分问题,MSBuild社区任务项目SDC任务库提供了大量的MSBuild任务,并且这两者均为免费使用。如果仍有缺失,那么你就只好寻求自助了。

Bart de Smet演示了如何创建调试自定义的MSBuild任务。他的第一篇文章介绍了如何创建自定义任务,第二篇文章则模仿了食谱的方式,对自定义任务的调试给与了关注。据Bart的介绍,开发一个自定义任务可以分为8步:

第1步:创建一个类库项目
第2步:导入引用
第3步:实现任务框架
第4步:任务的参数化
第5步:实现任务的功能
第6步:创建调试
第7步:设置断点并运行
第8步:高级调试
本质上,调试是在自定义MSBuild任务的项目属性中进行配置的:项目的启动行为(Start Action)必须设置为可执行的MSBuild(它应该匹配项目所引用的MSBuild程序集),同时,启动选项必须包含一个用于测试MSBuild项目的文件路径。

MSBuild团队博客提供了更多的信息与帮助,而Dan Moseley 与Xin Yan撰写的“MSBuilde功能大全以及未来的发展”一文,非常好的总结了MSBuild的特性、概念和在.NET 3.5中的新文件格式特性,以及未来的发展方向。
 
1  /  1  页   1 跳转

快速回复帖子

标题
禁用 URL 识别
禁用表情
禁用 Discuz!NT 代码
使用个人签名
  [完成后可按 Ctrl+Enter 无刷新发布]  

版权所有 拼吾爱程序人生    Total Unique Visitors:

web counter

Powered by Discuz!NT 2.1.202   Copyright © 2001-2008 Comsenz Inc. 鄂ICP备07500843号
返顶部