如何从命令行编译Visual Studio项目? [英] How do I compile a Visual Studio project from the command-line?

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

问题描述

我正在使用 Monotone CMake ,Visual Studio Express 2008,和定制测试。

I'm scripting the checkout, build, distribution, test, and commit cycle for a large C++ solution that is using Monotone, CMake, Visual Studio Express 2008, and custom tests.

所有其他部分看起来很简单,但我没有看到如何编译Visual Studio解决方案,而没有得到GUI。

All of the other parts seem pretty straight-forward, but I don't see how to compile the Visual Studio solution without getting the GUI.

脚本是用Python编写的,但是一个答案让我只需调用:os.system就可以。

The script is written in Python, but an answer that would allow me to just make a call to: os.system would do.

推荐答案

我知道有两种方法。

方法1

第一种方法(我更喜欢使用 msbuild

msbuild project.sln /Flags...

方法2

您还可以运行:

Method 2
You can also run:

vcexpress project.sln /build /Flags...

vcexpress选项立即返回,不打印任何输出。我想这可能是你想要的脚本。

The vcexpress option returns immediately and does not print any output. I suppose that might be what you want for a script.

请注意,DevEnv不是分布在Visual Studio Express 2008(我花了很多时间试图找出当我第一次有一个类似的问题)。

Note that DevEnv is not distributed with Visual Studio Express 2008 (I spent a lot of time trying to figure that out when I first had a similar issue).

因此,最终结果可能是:

So, the end result might be:

os.system("msbuild project.sln /p:Configuration=Debug")

确保您的环境变量是正确的,因为系统路径上的默认值不是msbuild和vcexpress。或者启动Visual Studio构建环境并从那里运行脚本,或者修改Python中的路径(使用 os.putenv )。

You'll also want to make sure your environment variables are correct, as msbuild and vcexpress are not by default on the system path. Either start the Visual Studio build environment and run your script from there, or modify the paths in Python (with os.putenv).

这篇关于如何从命令行编译Visual Studio项目?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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