3

我想使用MSBuild自动git bisect构建一个 .NET 项目(在官方 Linux Kernel Git 文档中git bisect也提供了说明) ,并使用. 但是,这些工具是为在 Windows 开发环境中使用而构建的,我在让它们在 msysgit 的 Bash 环境中工作时遇到了各种问题,总结如下:nunit-console.exe

  1. Bash 似乎找不到MSBuild.exe也找不到nunit-console.exe(路径问题)。
  2. 两者都MSBuild.exe使用nunit-console.exeWindows 风格的命令行选项标志,即它们以正斜杠开头,例如MSBuild.exe /M. 在 Bash 中,正斜杠会导致错误,因为 Unix/Linux/*nix 系统使用正斜杠来表示目录路径。

这是git bisect我一直在使用的命令:

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

这些是以下内容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."
4

1 回答 1

5

为了解决路径问题,我只是在脚本中使用了绝对路径。为了解决 Windows 风格的正斜杠命令行选项问题,我用另一个正斜杠转义了正斜杠(我从另一个 Stack Overflow 答案中得到了这个提示,当我再次找到它时会链接到它)。

所以现在工作脚本如下所示:

#!/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."

再一次,你像这样运行它:

$ git bisect start <bad commit> <good commit>
$ git bisect run auto-build-run-tests.sh
于 2013-07-28T01:41:34.607 回答