bash 找不到 `msbuild` 命令,但 `msbuild.exe` 工作正常

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/13819294/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-18 03:59:53  来源:igfitidea点击:

`msbuild` command not found, but `msbuild.exe` works fine

bashmsysgitmsys

提问by Colonel Panic

I run MSys/Bash as distributed in Git for Windows. I added the folder C:\Windows\Microsoft.NET\Framework\v4.0.30319to my path, so I could run msbuildbut it doesn't work

我在Git for Windows 中运行 MSys/Bash 。我将该文件夹添加C:\Windows\Microsoft.NET\Framework\v4.0.30319到我的路径中,所以我可以运行msbuild但它不起作用

$ msbuild
C:\Program Files (x86)\Git\bin\sh.exe: msbuild: command not found

Yet msbuild.exedoes:

然而msbuild.exe

$ msbuild.exe
Microsoft (R) Build Engine version 4.0.30319.17929

Yet the command explorerresolves fine. What's going on?

但是命令explorer解析得很好。这是怎么回事?

回答by Colonel Panic

It's a bug in MSys where the same name is shared by a folder and a file (minus the extension). In this case:

这是 MSys 中的一个错误,其中文件夹和文件(减去扩展名)共享相同的名称。在这种情况下:

  • File C:\Windows\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe
  • Folder C:\Windows\Microsoft.NET\Framework\v4.0.30319\MSBuild
  • 文件 C:\Windows\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe
  • 文件夹 C:\Windows\Microsoft.NET\Framework\v4.0.30319\MSBuild

You'll have to workaround by writing msbuild.exe

你必须通过写作来解决 msbuild.exe

回答by Greg Quinn

If msbuild.exe cannot be found, it needs to be configured.

如果找不到 msbuild.exe,则需要对其进行配置。

Open a command prompt and run the file vsvars32.bat located in your Visual Studio Common7/Tools folder..

打开命令提示符并运行位于 Visual Studio Common7/Tools 文件夹中的文件 vsvars32.bat。

i.e C:\Program Files x86\Microsoft Visual Studio 12.0\Common7\Tools\vsvars32.bat

即 C:\Program Files x86\Microsoft Visual Studio 12.0\Common7\Tools\vsvars32.bat

This will correctly setup all the neccessary variables for msbuild.exe to be found.

这将正确设置要找到的 msbuild.exe 的所有必要变量。