如何从命令行使用MSBuild进行构建? [英] How can I build all with MSBuild from the command line?

查看:132
本文介绍了如何从命令行使用MSBuild进行构建?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这有效吗?

MSBuild /t=all /configuration=all

我想使用Visual Studio 2008中的MSBuild从命令行在sln文件等中构建所有项目的所有配置.

I want to build ALL configurations of all projects in a sln file, etc from the command line using MSBuild in Visual Studio 2008.

当我调用MSBuild时,我不想指定它们,sln/proj文件都具有该信息.如果我将配置添加到项目文件中,我不想更改构建脚本.

I do not want to have to specify them when I call MSBuild, the sln/proj files all have that information. I don't want to change my build script if I add configurations to project files.

因此对于目标,我可以使用BuildAll.如果我将配置留空,那么它将全部构建还是"BuildALL"对配置有效?

So for the target I can use BuildAll. If I leave the configuration empty will it build all or is "BuildALL" valid for configuration as well?

编辑

基本上,我要问的是给出的SLN或VCProj文件,我希望msbuild可以迭代所有配置并自行构建,或者通过某种机制可以发现它们,因此我不必在命令行上专门列出它们或脚本中.

essentially what I am asking is given an SLN or VCProj file, I want msbuild to iterate all configurations and build it itself, or alternatively some mechanism that will discover them so I don't have to specifically list them on the command line or in a script.

即添加或删除配置时,我不想更新构建脚本.这似乎是一件很合理的事情.

i.e. I don't want to update my build script when I add or remove a configuration. That seems like a pretty reasonable thing to want to do.

推荐答案

默认情况下,您无法使用MSBuild命令行选项来构建所有配置.为此,您需要创建一个新目标(VS项目).

You can't by default build all configurations using MSBuild command line options. In order to do this you need to create a new target (VS Project).

我的操作方式是:

msbuild /t:BuildAll /Configuration:"Debug;Release;ContinuousIntegration"

我创建一个标准T​​arget,并将其命名为BuildAll,对于我要自动化的每个项目,我只需创建该Target,并使它依赖于您要自动构建的所有目标.

I make a standard Target, and call it BuildAll, and for every project I wanted to automate, I'd just create that Target and make it depend on all the targets you want to build automatically.

这篇关于如何从命令行使用MSBuild进行构建?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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