#!/bin/bash


if [ ! -d .git ];
then
	echo "in a git directory plz"
	exit 0
fi

IISPORTHTTPS='44356'
IISPORTDEV='61167'

REPO="$(pwd | xargs cygpath --windows | sed 's/\\/\\\\/g')"

echo "let change the .config for IISEXPRESS"

for FILE in $(find -iname "Lumed.Platform.Web.csproj*")
do
	if grep -qi "<IISExpressSSLPort>" "$FILE"
	then
		printf "$FILE";
		printf "."

		git update-index -q --assume-unchanged $FILE
		printf "."


		sed -i "s/\(<IISExpressSSLPort>\)\([0-9]*\)\(<\/IISExpressSSLPort>\)/\1$IISPORTHTTPS\3/IM" $FILE;
		printf "."


		sed -i "s/\(<IISUrl>https:\/\/localhost:\)\([0-9]*\)\(\/<\/IISUrl>\)/\1$IISPORTHTTPS\3/IM" $FILE;
		printf "."

		sed -i "s/\(<DevelopmentServerPort>\)\([0-9]*\)\(<\/DevelopmentServerPort>\)/\1$IISPORTDEV\3/IM" $FILE;
		printf "."
	fi
done

echo "done"

