Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Build all DotNet Projects in Directory
#!/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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.