how to use git command with MSBuild?

2k Views Asked by At

I'm thinking about using git submodules to retrieve dependencies of my git repository instead of committing binary files to my main repository (effectively only committing binary files to a different repository which I will be able to purge often --by purge I mean delete history to save space on the server...).

Problem is, how to call the GIT executable using MSBuild? In the developer machine git should already be in the path, but in the buildagents the path to git executable is going to come from an environment variable. How to figure out the git path then at compile time using MSBuild? I want to do a git pull of the git submodule every time I build.

Thanks

1

There are 1 best solutions below

5
On

You read the environment variables in MSBuild much the same way you would a property

So if the environment variable being passed is GIT_PATH, you can access it using $(GIT_PATH)

Supply this to the exec task along with the appropriate arguments