How do I compile a Visual Studio project from the command-line?(如何从命令行编译 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 项目?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何从命令行编译 Visual Studio 项目?


基础教程推荐
- C++结构和函数声明。为什么它不能编译? 2022-11-07
- 如何检查GTK+3.0中的小部件类型? 2022-11-30
- 常量变量在标题中不起作用 2021-01-01
- 如何在 C++ 中初始化静态常量成员? 2022-01-01
- 如何将 std::pair 的排序 std::list 转换为 std::map 2022-01-01
- 如何通过C程序打开命令提示符Cmd 2022-12-09
- 静态库、静态链接动态库和动态链接动态库的 .lib 文件里面是什么? 2021-01-01
- 我有静态或动态 boost 库吗? 2021-01-01
- 这个宏可以转换成函数吗? 2022-01-01
- 在 C++ 中计算滚动/移动平均值 2021-01-01