bash: msbuild: 命令未找到

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/43407685/
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 16:01:41  来源:igfitidea点击:

bash: msbuild: command not found

gitbashmsbuildmingwgit-bash

提问by keipa

Having a problem with adding msbuildto git bash for Win10

msbuildWin10 中添加到 git bash 时遇到问题

already added msbuildto system vars and to path too

已经添加msbuild到系统变量和路径

CMD msbuildcalls fine

CMDmsbuild调用正常

already tried this solution

已经尝试过这个解决方案

Git bash msbuild

git bash msbuild

Pathsystem var

小路系统变量

回答by stijn

If you want to refer to an environment variable you need to prefix it with $, like $msbuild. I'm not sure that is the best idea though, nor modifying the system path: what if you have different versions of msbuild?

如果你想引用一个环境变量,你需要在它前面加上前缀$,比如$msbuild。我不确定这是不是最好的主意,也不是修改系统路径:如果你有不同版本的 msbuild 怎么办?

Anyway, your real problem is that the command isn't msbuild, it is MSBuild.exe. And a convenient way of adding it to the mingw environment is making sure it is already in the path before starting bash. For example, create a batch file 'msbuild-git-bash.bat' in the same directory as git-bash.bat, containing

无论如何,您真正的问题是命令不是msbuild,而是MSBuild.exe。将它添加到 mingw 环境的一种便捷方法是确保它在启动 bash 之前已经在路径中。比如在git-bash.bat所在目录下创建一个批处理文件'msbuild-git-bash.bat',包含

call "C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\Tools\VsDevCmd.bat"
git-bash.bat

then use that instead and type msbuand hit tab to get command completion:

然后改用它并键入msbu并点击选项卡以获取命令完成:

enter image description here

在此处输入图片说明

Note this example is for VS2013, for other versions the path to vsdevcmd.bat will be different but the principle is the same. Also because of using it, nmake/cl/link/... are also all available.

注意这个例子是针对VS2013的,其他版本vsdevcmd.bat的路径会有所不同,但原理是一样的。也因为用了,nmake/cl/link/...也都可以用。

回答by Ferran Cabrera

I'm using Visual Studio 2017 for WPF development and I just wanted to build any .net framework application/library from git bash.
So, I just copied the following files
from: C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\Bin
into: C:\Program Files\Git\usr\binfolder and it worked like a charm:

我正在使用 Visual Studio 2017 进行 WPF 开发,我只想从 git bash 构建任何 .net 框架应用程序/库。
所以,我只是将以下文件
从: C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\Bin
到:C:\Program Files\Git\usr\bin文件夹中,它就像一个魅力:

Screenshot

截屏

Then, just go to any of your .csprojprojects and run msbuildcommand in your git bash.

然后,只需转到您的任何.csproj项目并msbuild在您的 git bash 中运行命令。

Hope it helps.

希望能帮助到你。

回答by gpresland

Use msbuild.exein git Bash instead of msbuild.

msbuild.exe在 git Bash 中使用而不是msbuild.