dotnet-installer/scripts/bootstrap.sh

95 lines
3.8 KiB
Bash
Raw Normal View History

2015-10-16 22:30:28 +00:00
#!/usr/bin/env bash
set -e
2015-10-16 22:30:28 +00:00
SOURCE="${BASH_SOURCE[0]}"
while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
SOURCE="$(readlink "$SOURCE")"
[[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located
done
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
2015-10-29 17:33:39 +00:00
source "$DIR/_common.sh"
[ -z "$CONFIGURATION" ] && CONFIGURATION=Debug
# TODO: Replace this with a dotnet generation
TFM=dnxcore50
2015-10-16 22:30:28 +00:00
REPOROOT="$( cd -P "$DIR/.." && pwd )"
START_PATH=$PATH
2015-10-16 22:30:28 +00:00
OUTPUT_ROOT=$REPOROOT/artifacts/$RID
DNX_DIR=$OUTPUT_ROOT/dnx
2015-10-16 22:30:28 +00:00
STAGE1_DIR=$OUTPUT_ROOT/stage1
STAGE2_DIR=$OUTPUT_ROOT/stage2
2015-10-29 17:33:39 +00:00
banner "Installing stage0"
2015-10-19 06:29:51 +00:00
2015-10-29 17:02:14 +00:00
source $DIR/dnvm2.sh
dnvm upgrade -a dotnet_stage0
DNX_ROOT="$(dirname $(which dotnet))/dnx"
2015-10-16 22:30:28 +00:00
2015-10-29 17:33:39 +00:00
banner "Restoring packages"
2015-10-29 17:33:39 +00:00
dotnet restore "$REPOROOT" --runtime osx.10.10-x64 --runtime ubuntu.14.04-x64 --runtime osx.10.11-x64 --quiet
2015-10-16 22:30:28 +00:00
# Clean up stage1
[ -d "$STAGE1_DIR" ] && rm -Rf "$STAGE1_DIR"
2015-10-29 17:33:39 +00:00
banner "Building stage1 using downloaded stage0"
dotnet publish --framework "$TFM" --runtime $RID --output "$STAGE1_DIR" --configuration "$CONFIGURATION" "$REPOROOT/src/Microsoft.DotNet.Cli"
dotnet publish --framework "$TFM" --runtime $RID --output "$STAGE1_DIR" --configuration "$CONFIGURATION" "$REPOROOT/src/Microsoft.DotNet.Tools.Compiler"
dotnet publish --framework "$TFM" --runtime $RID --output "$STAGE1_DIR" --configuration "$CONFIGURATION" "$REPOROOT/src/Microsoft.DotNet.Tools.Compiler.Csc"
dotnet publish --framework "$TFM" --runtime $RID --output "$STAGE1_DIR" --configuration "$CONFIGURATION" "$REPOROOT/src/Microsoft.DotNet.Tools.Publish"
dotnet publish --framework "$TFM" --runtime $RID --output "$STAGE1_DIR" --configuration "$CONFIGURATION" "$REPOROOT/src/Microsoft.DotNet.Tools.Resgen"
2015-10-16 22:30:28 +00:00
# Add stage1 to the path and use it to build stage2
export PATH=$STAGE1_DIR:$START_PATH
2015-10-16 22:30:28 +00:00
2015-10-22 06:41:38 +00:00
# Make corerun explicitly executable
chmod a+x $STAGE1_DIR/corerun
2015-10-28 21:35:29 +00:00
# Clean up stage2
[ -d "$STAGE2_DIR" ] && rm -Rf "$STAGE2_DIR"
2015-10-29 17:33:39 +00:00
banner "Building stage2 dotnet using compiled stage1 ..."
dotnet publish --framework "$TFM" --runtime $RID --output "$STAGE2_DIR" --configuration "$CONFIGURATION" "$REPOROOT/src/Microsoft.DotNet.Cli"
dotnet publish --framework "$TFM" --runtime $RID --output "$STAGE2_DIR" --configuration "$CONFIGURATION" "$REPOROOT/src/Microsoft.DotNet.Tools.Compiler"
dotnet publish --framework "$TFM" --runtime $RID --output "$STAGE2_DIR" --configuration "$CONFIGURATION" "$REPOROOT/src/Microsoft.DotNet.Tools.Compiler.Csc"
dotnet publish --framework "$TFM" --runtime $RID --output "$STAGE2_DIR" --configuration "$CONFIGURATION" "$REPOROOT/src/Microsoft.DotNet.Tools.Publish"
dotnet publish --framework "$TFM" --runtime $RID --output "$STAGE2_DIR" --configuration "$CONFIGURATION" "$REPOROOT/src/Microsoft.DotNet.Tools.Resgen"
2015-10-22 06:41:38 +00:00
# Make Stage 2 Folder Accessible
chmod -R a+r $REPOROOT
# Copy DNX in to stage2
cp -R $DNX_ROOT $STAGE2_DIR/dnx
# Copy and CHMOD the dotnet-restore script
cp $DIR/dotnet-restore.sh $STAGE2_DIR/dotnet-restore
chmod a+x $STAGE2_DIR/dotnet-restore
# Smoke-test the output
2015-10-29 17:33:39 +00:00
banner "Testing stage2 ..."
export PATH=$STAGE2_DIR:$START_PATH
2015-10-30 02:45:55 +00:00
rm "$REPOROOT/test/TestApp/project.lock.json"
dotnet restore "$REPOROOT/test/TestApp" --runtime "$RID"
dotnet publish "$REPOROOT/test/TestApp" --framework "$TFM" --runtime "$RID" --output "$REPOROOT/artifacts/$RID/smoketest"
2015-10-29 17:33:39 +00:00
OUTPUT=$($REPOROOT/artifacts/$RID/smoketest/TestApp)
[ "$OUTPUT" == "This is a test app" ] || (error "Smoke test failed!" && exit 1)
# Check that a compiler error is reported
set +e
2015-10-28 21:35:29 +00:00
dotnet compile "$REPOROOT/test/compile/failing/SimpleCompilerError" --framework "$TFM" 2>/dev/null >/dev/null
rc=$?
if [ $rc == 0 ]; then
2015-10-29 17:33:39 +00:00
error "Compiler failure test failed! The compiler did not fail to compile!"
exit 1
fi
set -e