Skip to content

Instantly share code, notes, and snippets.

@jaredcnance
Last active February 2, 2018 21:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jaredcnance/66e2755336331a97ad888d8c14c99aa4 to your computer and use it in GitHub Desktop.
Save jaredcnance/66e2755336331a97ad888d8c14c99aa4 to your computer and use it in GitHub Desktop.
#!/bin/sh
#
# This is a pre-commit script that will automatically ensure any new .csproj files
# have been added to the AllProjects solution. AllProjects the solution used on the build
# server and must be kept up to date.
#
# This will fail if you do not have VS 2017+ or the dotnet-cli installed.
solution="AllProjects.sln"
add_to_solution() {
dotnet sln $solution add $1
git add $solution
return 0
}
git diff --cached --name-only --diff-filter=A | while read -r line ; do
if `echo ${line} | grep '**/*.csproj$' 1>/dev/null 2>&1`
then
add_to_solution $line
fi
done
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment