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

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

问题描述

我正在为使用 单调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.

所有其他部分看起来都很简单,但我不知道如何在没有 GUI 的情况下编译 Visual Studio 解决方案.

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.

推荐答案

我知道有两种方法可以做到.

I know of two ways to do it.

方法一
第一种方法(我更喜欢)是使用 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天全站免登陆