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

我们两清 提交于 2019-11-28 08:14:22

问题


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

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

Yet msbuild.exe does:

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

Yet the command explorer resolves fine. What's going on?


回答1:


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

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

You'll have to workaround by writing msbuild.exe




回答2:


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

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

i.e 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.



来源:https://stackoverflow.com/questions/13819294/msbuild-command-not-found-but-msbuild-exe-works-fine

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!