Created
July 26, 2011 14:14
-
-
Save timabell/1106855 to your computer and use it in GitHub Desktop.
Quick script to check the hint paths in a visual studio sln file are valid
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# use "dephunter.sh -v" for verbose mode | |
verbose=false | |
if [ "$1" == "-v" ] | |
then | |
verbose=true | |
echo verbose mode | |
fi | |
if $verbose | |
then | |
echo "relevant project files:" | |
find . -iname *.csproj | |
echo | |
echo | |
fi | |
errorsFound=false | |
IFS=$'\n' # prevent spaces in filenames breaking loop over find results | |
for projectFile in `find . -iname *.csproj` | |
do | |
grep -i hintpath "$projectFile" > /dev/null | |
if [ $? -ne 0 ] | |
then | |
if $verbose | |
then | |
echo "Skipping project, no hintpath entries in $projectFile" | |
fi | |
continue | |
fi | |
dependencies=`sed -n -e '/HintPath/s/.*HintPath>\(.*\)<.*/\1/p' "$projectFile";` | |
if $verbose | |
then | |
echo "dependency hints in project file $projectFile" | |
echo "$dependencies" | |
echo | |
fi | |
projectFolder=${projectFile%/*} | |
if $verbose | |
then | |
echo "changing working directory to project folder: $projectFolder" | |
fi | |
cd "$projectFolder" | |
shownProject=false | |
while read -r dependency; | |
do | |
dependency="${dependency//\\//}" # flip windows paths to unix paths for ls | |
if $verbose | |
then | |
echo "checking $dependency" | |
ls -l "$dependency" | |
else | |
ls "$dependency" &> /dev/null | |
fi | |
if [ $? -ne 0 ] | |
then | |
if ! $shownProject; then | |
echo | |
echo "Project: $projectFile"; | |
shownProject=true | |
fi | |
echo "NOT FOUND - $dependency" | |
errorsFound=true | |
else | |
if $verbose | |
then | |
echo "Found - $dependency" | |
fi | |
fi | |
done <<< "$dependencies" | |
cd - > /dev/null #go back to original directory | |
done | |
if ! $errorsFound; then | |
echo "No broken hint paths found." | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment