使用 MSBuild 构建解决方案文件夹
我们有一个解决方案文件,其中包含一些解决方案文件夹:库、单元测试、应用程序等。
Visual Studio 2010 我们可以通过右键单击给定文件夹并使用“构建”或“重建”来仅构建给定文件夹的项目。
这对于开发人员的工作站来说是完美的,我们希望在使用 MSBuild 的持续集成服务器上做同样的事情。
那么,我们可以用MSBuild构建一个解决方案文件夹吗?
或者我们是否必须为每个文件夹创建专用的解决方案?
以下回复的结论是,没有任何内置方法可以做到这一点,但有一些解决方法:
- 仅使用选定的项目创建专用解决方案,
- 使用专用 csproj< /strong> 将构建所选项目,
- 添加一个将引用现有解决方案文件中所选项目的新项目。
我选择使用专用解决方案文件,因为它是侵入性较小且棘手的方法,但不是更灵活(专用 .csproj 解决方案应提供完全控制)。
We have a solution file that contains some solution folders: libraries, unit-tests, applications, etc.
With Visual Studio 2010 we can build only the projects of a given folder by right-clicking on it and using "build" or "rebuild".
This is perfect on the developers' workstations, and we'd like to do the same on the continuous-integration server which uses MSBuild.
So, can we build a solution folder with MSBuild?
Or will we have to create a dedicated solution for each folder?
The conclusion of the below responses is that there isn't any built-in way to do that, but some workarounds:
- create a dedicated solution with only the selected projects,
- use a dedicated csproj that will build the selected projects,
- add a new project which will reference the selected projects in the existing solution file.
I've chosen to use a dedicated solution file as it is the less intrusive and tricky way, though not the more flexible (the dedicated .csproj solution should offer full control).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
是的,您可以使用 MSBuild 构建解决方案文件夹。
将在名为 First 的文件夹中构建项目。 但是,磁盘文件夹和解决方案文件夹必须匹配(我在我的解决方案中尝试了它,但它们首先不匹配)。
因此,您所要做的就是选择一个项目,该项目将该文件夹中的所有其他项目都作为依赖项。
另请参阅:
MSBuild 命令行参考
Yes, you can build Solutions folders using MSBuild.
will build the project in the folder called First. However, disk folders and solutions folders must match (I tried it for my solution where they don’t first).
So all you'd have to do is choose a project that has all the other projects in that folder as dependencies.
Also see:
MSBuild command-line reference
简短的回答是:
您不必创建(和维护)Visual Studio 解决方案来支持您的构建,但最终它是相同的(MSBuild .proj 与 Visual Studio 解决方案)。
我有一个类似的场景,有一组 60 多个 .NET 项目 (.btprpj BizTalk)。为了在 Visual Studio 中进行开发,这些项目目前分为 12 个 Visual Studio 解决方案。
为了实现自动化构建和部署,我创建了一组 50 多个 MSBuild .proj 脚本来定位我需要的每个组件(或一组组件)。
MSBuild 提供了很多自动化 Visual Studio 项目实际构建(从版本控制系统导出等)的所有内容的可能性。
The short answer is:
You will not have to create (and maintain) Visual Studio solutions to support your build, but in the end it's the same (an MSBuild .proj vs. a Visual Studio solution).
I have a similar scenario with a set of 60+ .NET projects (.btprpj BizTalk). For developing in Visual Studio, these projects are currently organized in 12 Visual Studio solutions.
For automated build and deploy I created a set of 50+ MSBuild .proj scripts to target every single component (or set of components) I need.
MSBuild offers a lot of possibilities for automating all the stuff around the actual build of the Visual Studio projects (export from version control systems, etc.).