8

Having a problem with adding msbuild to git bash for Win10

already added msbuild to system vars and to path too

CMD msbuild calls fine

already tried this solution

Git bash msbuild

Path system var

Community
  • 1
  • 1
keipa
  • 702
  • 1
  • 8
  • 17

4 Answers4

8

Use msbuild.exe in Git Bash instead of msbuild.

gpresland
  • 1,690
  • 2
  • 20
  • 31
2

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?

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

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

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

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.

stijn
  • 34,664
  • 13
  • 111
  • 163
  • It's a pretty good advice, BUT my user permissions does not allow me to execute *.bat* files. Thank you for your help, man – keipa Apr 14 '17 at 15:14
  • So you don't use git-bash.bat for starting bash but just the exe? There might be ways around that, not sure. Can you do something like `cmd /c some.bat`? – stijn Apr 14 '17 at 15:53
1

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\bin folder and it worked like a charm:

Screenshot

Then, just go to any of your .csproj projects and run msbuild command in your git bash.

Hope it helps.

JustBaron
  • 2,319
  • 7
  • 25
  • 37
0

If you are using cmder with bash, then you could define an alias like

alias msbuild='msbuild.exe'

(the path to msbuild.exe must be already set in PATH)

Adrian Iftode
  • 15,465
  • 4
  • 48
  • 73