c++ - 无法从命令行 VS2017 为 C++ 运行 msbuild

标签 c++ command-line msbuild visual-studio-2017

我有一个只存在于 Visual Studio 2017 中的项目。它是一个 C++ dll,到目前为止,我在 Visual Studio GUI 中构建它时没有遇到任何问题。但是现在我正在尝试设置自动化,它将在命令行上构建项目并将输出文件上传到所需位置。到目前为止,这是我尝试过的(在全新的命令提示符中):

cd C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC>
vcvarsall amd64
cd C:\Users\me\development\MyProject
msbuild MyProject.slnl (or msbuild MyProject\MyProject.vcxproj)

这给了我错误输出

C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\v140\Microsoft.Cpp.Platform.targets(57,5): 
error MSB8020: The build tools for v141 (Platform Toolset = 'v141') cannot be found. To build
using the v141 build tools, please install v141 build tools.  Alternatively, you
may upgrade to the current Visual Studio tools by selecting the Project menu or right-cli
ck the solution, and then selecting "Retarget solution". 
[C:\Users\dev\development\MetaReme\MetaReme\MetaReme.vcxproj]

让我重申一下,我已经在 Visual Studio 2017 中成功构建了针对 v141 工具集的内容,只是在命令行上我遇到了问题。在我的 Visual Studio 安装程序应用程序中,我检查了 VC++ 2017 v141 工具集。我查看了文件系统并在 C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\ 内没有v141文件夹。

谢谢!

最佳答案

谢谢大家!我在关注 https://learn.microsoft.com/en-us/cpp/build/building-on-the-command-line上面写着“默认情况下,这些工具安装在 drive:\Program Files (x86)\Microsoft Visual Studio version\VC\bin 中。”。显然这些文档已经过时了......我能够使用以下命令让它工作

cd "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build"
vcvars64
cd "C:\Users\me\development\MyProject"
msbuild MyProject.sln

关于c++ - 无法从命令行 VS2017 为 C++ 运行 msbuild,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44552647/

相关文章:

c++ - 如何编写像 "size_t s = 16 MByte"这样的文字常量?

c++ - 在 C++ 中获取 ncurses chtype 或 unsigned char 的整数值

c++ - Visual C++ 6.0 中 "unsigned char"数组的最大允许大小是多少?

c++ - 在特定的 Unicode 路径中创建文件

c - 如何从 C 命令行读取星号 ( * ) 作为参数

c# - 为什么我的测试二进制文件被复制到 TestResults\<somepath>\out 文件夹中?

linux - CMake,构建选项

c - 错误地址 C(命令行解释器)

msbuild - 所有目标未被调用(嵌套目标未被执行)

iis-7 - AppPool 已停止时如何防止出现错误消息