MSBuild 扩展包与 MSBuild 社区任务
我刚刚开始第一次制作自定义 MSBuild 脚本。我看到有两个用于扩展功能的标准选项: MSBuild Extension Pack 和 MSBuild 社区任务。
我正在寻找一些指导,了解它们之间的差异,以及为什么我会使用其中一种而不是另一种,甚至两者都使用。我在 Bing 上搜索过,但只见树木不见森林。任何指导表示赞赏。
I am just starting to make custom MSBuild scripts for the first time. I see that there are two standard options for extending the features: MSBuild Extension Pack and MSBuild Community Tasks.
I am looking for some guidance about what the differences are between these, and why I would use one over the other, or even both. I have Googled on Bing, but can't see the wood for the trees. Any guidance appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我插一句,只值2美分。有几件事——首先,我不会确切地称它们为“标准”选项。两者都早于 MSBuild 4.0,内联任务和属性函数功能以及其中的许多任务几乎已经过时。我已经编写了数千行 MSBuild,并且只需要几次来自这些库的任务。
它们的优点在于它们非常模块化。您可以仅选择您需要的程序集和目标文件,并将它们签入您的代码库,而不会“卡在”整个实现中。有时,我会从一个库中挑选一项任务,并从另一个库中挑选一项任务,两者都在同一构建中。我总是更喜欢使用简单的 MSBuild 4.0 功能而不是库中的功能。我对库中的一些任务感兴趣,但这些行为根本不是我需要的,所以我自己做了一个(对于这个任务,我想到了 zip 任务,因为我想控制分组中的压缩与源文件夹不关联)。一旦您必须编写一个自定义任务,就可以很容易地在同一个程序集中滚动另一个任务。
最后,我想说,这并不是真正与库有关,而是与您对库中特定任务的非常具体的需求有关,使用您需要的东西,并且不要将您的构建与除此之外的任何东西混淆那。
I'll chime in, just 2 cents worth. Couple of things -- first of all I wouldn't exactly call them "standard" options. Both predate MSBuild 4.0 and the inline task and property function features and many of the tasks in them are pretty much obsolete. I've written thousands of lines of MSBuild and have only ever needed tasks from either of those libraries a couple times.
What is nice about them is that they are pretty modular. You can pick and choose only the assemblies and targets files you have need of and check them into your code base without getting "stuck" with the entire implementation. At times I've cherry-picked a task from one library and a task from the other, both in the same build. I always prefer using simple MSBuild 4.0 features over something in the library. I've had interest in some of the tasks in the library but the behavior wasn't at all what I needed so I whipped up my own (the zip tasks comes to mind for this one, since I wanted to control zipping in groups that didn't correlate to the source folders). Once you have to write a single custom task it becomes really easy to roll another and another, all in the same assembly.
In the end, I would say that it isn't really about the library so much as it is about the very specific need you have for particular tasks in the library, use what you need and don't tangle up your build with anything but that.
我目前在工作中使用 MSBuild 社区任务。我没有接触过其他扩展,但我可以告诉一些关于这个库的事情。
优点:
缺点:
我的同事编写了数千个 sql 脚本,全部采用 ANSI 编码。当我替换其中的内容并将它们传递给 SQLCMD 时,它无法解析文件,因为所有 UTF-8 文件末尾添加了一个符号(某种编码符号)。我需要转到 RegexReplace.cs,更改函数之一中的编码参数,然后编译它。所以基本上我需要创建我的叉子:)
(两分钟的工作,一小时的向人们解释它是如何工作的)
但是MSBuild解析UTF-8文件没有问题,所以我认为只有在使用外部工具处理文件时才可能遇到问题。
摘要:
这是一个有用的工具,易于安装和使用,它可以帮助你的代码更清晰、更容易理解,并且可以节省一些时间。我认为最大的问题是文档,但你可以在谷歌中写下任务和库的名称,并在论坛、博客和此处找到一些代码。
I am currently using MSBuild Community Tasks in my work. I didn't have contact with other extensions, but I can tell few things on this library.
Pros:
Cons:
My co-workers wrote like thousands of sql scripts, all encoded in ANSI. When i replaced stuff in them, and passed them to SQLCMD, then it wasn't able to parse the files, because of one sign added at the end of all UTF-8 files (some kind of encoding sign). I needed to go to RegexReplace.cs, change the encoding parameter in one of functions, and then compile it. So basically I needed to create my fork : )
(Two minutes of work, one hour of explaining people how it works)
But there was no problem with MSBuild parsing UTF-8 files, so I think you may encounter problems only when working with external tools to process files.
Summary:
This is an useful tool, easy to install and use, it can help to make your code a lot clearer, easier to understand, and it can save some time. I think the biggest problem is documentation, but you can just write name of task and library in google and find some code on forums, blogs and here.
我的 2 美分 - 我遇到的情况是,我必须快速为要在普通 Windows 计算机(未安装 TFS 和 VS.NET)上运行的项目创建构建脚本。构建脚本应该执行以下操作 -
我必须超越 MSBuild 4.0,因为我想要一种简单的方法来运行上面提到的工具以及发送电子邮件。我查看了 MSBuild 社区任务和 MSBuild 扩展包。虽然我读到扩展包是一个复杂的健康包,但我仍然尝试过,但最终我使用了社区包,因为它真的很容易使用,甚至与其他包相比还可以扩展代码,即使文档较少或没有文档。在我看来,只有当您有时间了解如何使用扩展包时,扩展包才是一个选择。
My 2 cents - I was in a situation where I had to quickly create a build script for a project that was to be run on a vanilla Windows machine (without TFS and VS.NET installed). The build script was supposed to do the following -
I had to look beyond MSBuild 4.0, since I wanted an easy way to run the tools mentioned above and also send email. I looked at both MSBuild Community Tasks and also MSBuild Extension pack. While I have read that the extensions pack is a sophisticated wholesome package, I still had a try but I ended up using Community pack as it was really easy to use and even extend the code as compared to the other, EVEN with less or no documentation. Extensions Pack, in my opinion is an option only if you have time to understand how to work with it.