如何使用 Windows SDK 7.1 从命令行运行 msbuild? [英] How do I run msbuild from the command line using Windows SDK 7.1?

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

问题描述

我正在我们的 CI 服务器上设置 .NET 4.0 支持.我已经安装了 .NET 4.0,以及来自 Windows 7.1 SDK 的 .NET 工具.

I'm setting up .NET 4.0 support on our CI server. I've installed .NET 4.0, and the .NET tools from the Windows 7.1 SDK.

在 .NET 2.0 和 3.5 上,这很有效.使用 .NET 4,当我从开始"菜单运行Windows SDK 7.1 命令提示符"时,它会抱怨

On .NET 2.0 and 3.5, that just worked. With .NET 4, when I run the "Windows SDK 7.1 Command Prompt" from the Start menu, it complains about

The x86 compilers are not currently installed. x86-x86
Please go to Add/Remove Programs to update your installation.
.
Setting SDK environment relative to C:Program FilesMicrosoft
SDKsWindowsv7.1
.
Targeting Windows Server 2008 x86 Debug

然后当我尝试运行 msbuild 时,我得到:

Then when I try to run msbuild, I get:

C:Program FilesMicrosoft SDKsWindowsv7.1>msbuild
'msbuild' is not recognized as an internal or external command,
operable program or batch file.

C:Program FilesMicrosoft SDKsWindowsv7.1>

我不敢相信安装运行时和 SDK 会留下一个无法运行 msbuild 的系统...我是否错过了一些明显的步骤或晦涩难懂的 Windows 更新,或者是时候放弃并开始破解系统路径?

I can't quite believe that installing the runtime and SDK will leave you with a system that can't run msbuild... have I missed some obvious step or obscure Windows Update, or is time to give up and start hacking the system path?

推荐答案

要在命令提示符中启用msbuild,你只需要添加的目录msbuild.exe 在你的机器上安装到 PATH 环境变量.

To enable msbuild in Command Prompt, you simply have to add the directory of the msbuild.exe install on your machine to the PATH environment variable.

您可以通过以下方式访问环境变量:

You can access the environment variables by:

  1. 右键单击计算机
  2. 点击属性
  3. 然后点击左侧导航栏的高级系统设置
  4. 在下一个对话框中点击环境变量
  5. 向下滚动到 PATH
  6. 编辑它以包含您的框架路径(不要忘记此处最后一个条目后的;").

作为参考,我的路径是 C:WindowsMicrosoft.NETFrameworkv4.0.30319

For reference, my path was C:WindowsMicrosoft.NETFrameworkv4.0.30319

从 MSBuild 12 (2013)/VS 2013/.NET 4.5.1+ 及更高版本开始 MSBuild 现在作为 Visual Studio 的一部分安装.

As of MSBuild 12 (2013)/VS 2013/.NET 4.5.1+ and onward MSBuild is now installed as a part of Visual Studio.

对于 VS2015,路径是 %ProgramFiles(x86)%MSBuild14.0Bin

对于 VS2017,路径是 %ProgramFiles(x86)%Microsoft Visual Studio2017<YOUR_VS_EDITION>MSBuild15.0Bin

对于 VS2019,路径为 %ProgramFiles(x86)%Microsoft Visual Studio2019<YOUR_VS_EDITION>MSBuildCurrentBin

其中 <YOUR_VS_EDITION> 与您已安装的 Visual Studio 版本匹配,即 PreviewCommunityProfessional, 企业版.

where <YOUR_VS_EDITION> matches the Visual Studio edition that you have installed, i.e., Preview, Community, Professional, Enterprise.

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

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