将MSBuild集成到Visual Studio中 [英] Integrating MSBuild into Visual Studio

查看:64
本文介绍了将MSBuild集成到Visual Studio中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是一个独立开发人员,正在运行Visual Studio 2008,并希望通过MSBuild来改善我的构建过程.

I'm a solo developer running Visual Studio 2008 and looking into MSBuild to improve my build process.

到目前为止,我发现的几乎所有教程都包含有关编写构建文件的大量信息.但是我在寻找如何将MSBuild集成到Visual Studio中时遇到了很多麻烦.也许MSBuild仅与CruiseControl之类的东西一起使用,但是作为一个开发人员,这对于我来说太过分了.

Almost all of the tutorials I've found so far have plenty of information about writing a build file. However I'm having a lot of trouble finding out how to integrate MSBuild into Visual Studio. Maybe MSBuild is only used with something like CruiseControl but that's overkill for me as a single developer.

该构建文件应存放在Visual Studio项目中的什么位置,如何在IDE中运行它?

Where should the build file live in a Visual Studio project and how can I run it from within the IDE?

推荐答案

Visual Studio会为其支持的项目自动执行MSBuild.

Visual Studio executes MSBuild automatically for projects it supports.

如果右键单击一个项目并将其卸载,则可以在Visual Studio中对其进行编辑.重新加载(再次右键单击项目),强制(重新)构建以测试您的更改.一种替代方法是在外部编辑器中编辑项目文件,Visual Studio会检测到保存并提议为您重新加载项目.

If you right click on a project and unload it, you can then edit it in Visual Studio. Reload (right click on project again), force a (re)build to test your changes. An alternative is to edit the project file in an external editor and Visual Studio will detect saves and offer to reload the project for you.

听起来像在正确的轨道上,并且如果您正在考虑编写目标或自定义MSBuild任务,请花一些时间将它们与当前项目分开,以便您可以重新使用它们.不过,不要重新发明轮子,两个主要的互补MSBuild项目是 MSBuild社区任务 MSBuild扩展包.

Sounds like you're on the right track, and if you are considering writing Targets or custom MSBuild Tasks, take the time to separate them from your current project so that you can re-use them. Don't re-invent the wheel though, the two main complementary MSBuild projects are MSBuild Community Tasks and MSBuild Extension Pack.

更新:从对Mitch答案的评论来看,您可能还需要考虑向项目添加新的Configuration元素或自定义属性.一个新的MSBuild配置(除默认的Debug/Release之外的其他东西)可以运行单元测试,构建文档或任何您想自动化的东西.自定义MSBuild属性将允许您使用常规的调试/发布配置和命令行驱动.

Update: Judging from your comment on Mitch's answer, you might also want to consider adding a new Configuration element or custom properties to a project. A new MSBuild Configuration (something other than the default Debug/Release) could run unit tests, build documentation, or whatever you want automated. A custom MSBuild property would allow you to use normal Debug/Release Configuration and extend it to automate more of your build process, just depends on what you want. Either approach could also be driven from the command line.

这篇关于将MSBuild集成到Visual Studio中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆