繁体   English   中英

在msysgit中自动执行git bisect for MSBuild / NUnit / .NET / Windows批处理命令?

[英]Automate git bisect for MSBuild/NUnit/.NET/Windows batch commands in msysgit?

我想自动化git bisect用于git bisect官方Linux Kernel Git文档中的说明 ),用于使用MSBuild构建.NET项目,并使用nunit-console.exe为它运行单元测试。 但是,这些工具是为在Windows开发环境中使用而构建的,我遇到了使它们在msysgit的Bash环境中工作的各种问题,总结如下:

  1. Bash似乎无法找到MSBuild.exenunit-console.exe (路径问题)。
  2. MSBuild.exenunit-console.exe使用Windows样式命令行选项标志,即它们以foward斜杠开头,例如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."

为了解决路径问题,我只是在脚本中使用了绝对路径。 为了解决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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM