Skip to content

Instantly share code, notes, and snippets.

@craigiswayne
Created July 12, 2019 08:35
Show Gist options
  • Save craigiswayne/952c3f11fb45e8bf9eb8232bb6c84795 to your computer and use it in GitHub Desktop.
Save craigiswayne/952c3f11fb45e8bf9eb8232bb6c84795 to your computer and use it in GitHub Desktop.

Revisions

  1. craigiswayne created this gist Jul 12, 2019.
    33 changes: 33 additions & 0 deletions find-and-build-all.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,33 @@
    #!/bin/bash

    ###########################################################################################
    # Find's All *.csproj files in a directory
    # then executes a dotnet build on that project
    # if the build fails, it will stop the script execution
    ###########################################################################################
    separator="===============================================================================";
    search="*.csproj"
    startingDirectory=$PWD;
    echo $separator;
    echo "Finding all $search files in $PWD...";
    echo $separator;
    filesFound=$(find "$PWD" -name $search -type f);
    for i in $filesFound
    do
    filename=$(basename $i);
    echo "Building $filename..."
    echo "";
    cd $(dirname $i);
    dotnet build;
    result=$?;
    echo "Result: $result";
    echo "";
    if [ $result -gt 0 ]
    then
    echo "Failed to build $i";
    cd $startingDirectory;
    break;
    fi
    echo $separator;

    done