Automate git bisect for MSBuild / NUnit / .NET / Windows command commands in msysgit?

I would like to automate git bisect (instructions are also available in the official Linux Kernel Git documenation for git bisect ) to create a .NET project with MSBuild and run unit tests with nunit-console.exe . However, these tools were created for use in the Windows development environment, and I am having various problems making them work in the Bash environment for msysgit, which summarizes as follows:

  • Bash cannot find MSBuild.exe and nunit-console.exe (path problem).
  • Both MSBuild.exe and nunit-console.exe use the Windows-style command line options flags, that is, they start with a slash, for example. MSBuild.exe /M In Bash, forward slashes result in errors because the slash is what Unix / Linux / * nix systems use to represent directory paths.

This is the git bisect command I used:

 $ git bisect start <bad commit> <good commit> $ git bisect run auto-build-run-tests.sh 

and this is the contents of auto-build-run-tests.sh :

 #!/bin/sh # http://tldp.org/LDP/Bash-Beginners-Guide/html/sect_03_02.html # http://tldp.org/LDP/Bash-Beginners-Guide/html/sect_07_01.html # Build solution. echo "Building..." MSBuild.exe \ /consoleloggerparameters:ErrorsOnly \ /maxcpucount \ /nologo \ /property:Configuration=Debug \ /verbosity:quiet \ "Epic-Project-of-Supreme-Awesome.sln" # Check exit status. # (status != 0) ? status=$? if [ $status -ne 0 ] then echo "Build failure, status $status." exit $status fi echo "Build success." # Run unit tests nunit-console.exe \ /noresult \ /stoponerror \ "bin/Debug/ArtificialIntelligence.Tests.dll" \ "bin/Debug/TravelingSalesManSolver.Tests.dll" status=$? if [ $status -ne 0 ] then echo "Test failure, status $status." exit $status fi echo "Tests passed." 
+2
git msysgit bash nunit msbuild
source share
1 answer

To solve the path problem, I just used the absolute path in the script. To solve the Windows-style command-line-style command line issue, I avoided a forward slash using a different slash (I got this tip from another stack overflow answer, I will contact it when I find it again).

So now the working script looks like this:

 #!/bin/sh # http://tldp.org/LDP/Bash-Beginners-Guide/html/sect_03_02.html # http://tldp.org/LDP/Bash-Beginners-Guide/html/sect_07_01.html # Build solution. echo "Building..." c:/Windows/Microsoft.NET/Framework/v4.0.30319/MSBuild.exe \ //consoleloggerparameters:ErrorsOnly \ //maxcpucount \ //nologo \ //property:Configuration=Debug \ //verbosity:quiet \ Epic-Project-of-Supreme-Awesome.sln # Check exit status. # (status != 0) ? status=$? if [ $status -ne 0 ] then echo "Build failure, status $status." exit $status fi echo "Build success." # Run unit tests nunit-console.exe \ //noresult \ //stoponerror \ bin/Debug/ArtificialIntelligence.Tests.dll \ bin/Debug/TravelingSalesManSolver.Tests.dll status=$? if [ $status -ne 0 ] then echo "Test failure, status $status." exit $status fi echo "Tests passed." 

and again, you run it like this:

 $ git bisect start <bad commit> <good commit> $ git bisect run auto-build-run-tests.sh 
+4
source share

All Articles