#!/bin/sh

set -e

PROJECT_DIR="$(dirname $0)"

cd "$PROJECT_DIR"

TMPFILE=$(mktemp -u)
MAINFILEINFO=Main.InstallerConfig.cs
VERSION=$(grep 'string AssemblyVersion' $MAINFILEINFO | sed -e 's/.*\= //' -e 's/;.*//')

cp Properties/AssemblyInfo.template "$TMPFILE"
sed -i "s/PLACE_HOLDER/$VERSION/g" $TMPFILE
cp "$TMPFILE" Properties/AssemblyInfo.generated.cs
rm -rf $TMPFILE

perl -p -i -e "s/AssemblyInformationalVersion\(\".*\"\)/AssemblyInformationalVersion\(\"`date`\"\)/" Properties/AssemblyInfo.generated.cs

