Question

I am working on a project where most of the work is done in Visual Studio 2012, implicitly using MSBuild. However I have to integrate a few unixy tools, and I even have a few bash scripts. This is possible, because we are already using msysgit; the tools and scripts work just fine if you invoke them from the git-bash shell. But I want to run some of them from MSBuild as pre/post build actions.

The problem is how does MSBuild find bash? We assume it exists, but developers simply install it on their PC's in different locations, and will rarely add it to their %PATH%. I want a solution that involves a minimum of per-PC configuration. Ideally none at all.

Was it helpful?

Solution

I think the easiest way is to define a sensible default for your MsBuild solution and let it be overriden by developers on an as needed basis. Asking for bash or git to be on %PATH% is a reasonable default hence you could describe it as such

<PropertyGroup>
  <BashCommand Condition="'$(BashCommand)' == ''">bash</BashCommand>
</PropertyGroup>

This way any developer who wanted to override the setting could do so by defining the value before importing the core MsBuild files

OTHER TIPS

On the assumption that you are talking about the user installation (which we typically call Git for Windows) -- as opposed to the developer installation allowing you to develop Git for Windows itself (which we actually call msysGit) -- then you should be able to simply assume that Git is installed either in %ProgramFiles% or in %ProgramFiles(x86)%. You could even add a third option, say, %GitForWindows% which the users could set if they installed it elsewhere.

If that is not good enough, I am certain that the InnoSetup installer (or Windows' Installed Software management) leaves some trace in the registry, although that might be a little fragile: you would depend on that registry key not changing, ever.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top