2015-10-16 22:30:28 +00:00
#!/usr/bin/env bash
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 ) "
REPOROOT = " $( cd -P " $DIR /.. " && pwd ) "
echo "Bootstrapping dotnet.exe using DNX"
2015-10-16 22:56:34 +00:00
if [ -z " $RID " ] ; then
UNAME = $( uname)
if [ " $UNAME " = = "Darwin" ] ; then
RID = osx.10.10-x64
elif [ " $UNAME " = = "Linux" ] ; then
# Detect Distro?
RID = ubuntu.14.04-x64
else
echo " Unknown OS: $UNAME " 1>& 2
exit 1
fi
2015-10-16 22:30:28 +00:00
fi
OUTPUT_ROOT = $REPOROOT /artifacts/$RID
2015-10-20 16:05:17 +00:00
DNX_DIR = $OUTPUT_ROOT /dnx
2015-10-18 11:02:58 +00:00
STAGE0_DIR = $OUTPUT_ROOT /stage0
2015-10-16 22:30:28 +00:00
STAGE1_DIR = $OUTPUT_ROOT /stage1
STAGE2_DIR = $OUTPUT_ROOT /stage2
2015-10-19 07:10:55 +00:00
echo "Cleaning artifacts folder"
rm -rf $OUTPUT_ROOT
2015-10-20 16:05:17 +00:00
echo "Installing stage0"
# Use a sub-shell to ensure the DNVM gets cleaned up
mkdir -p $STAGE0_DIR
$DIR /install-stage0.sh $STAGE0_DIR $DIR /dnvm2.sh
rc = $? ; if [ [ $rc != 0 ] ] ; then exit $rc ; fi
2015-10-19 07:10:55 +00:00
2015-10-20 16:05:17 +00:00
export PATH = $STAGE0_DIR /bin:$PATH
2015-10-16 22:30:28 +00:00
export DOTNET_CLR_HOSTS_PATH = $REPOROOT /ext/CLRHost/$RID
2015-10-20 16:05:17 +00:00
if ! type dnx > /dev/null 2>& 1; then
echo "Installing and use-ing the latest CoreCLR x64 DNX ..."
mkdir -p $DNX_DIR
2015-10-19 06:35:43 +00:00
2015-10-20 16:05:17 +00:00
export DNX_HOME = $DNX_DIR
export DNX_USER_HOME = $DNX_DIR
export DNX_GLOBAL_HOME = $DNX_DIR
2015-10-19 06:29:51 +00:00
2015-10-20 16:05:17 +00:00
if ! type dnvm > /dev/null 2>& 1; then
curl -o $DNX_DIR /dnvm.sh https://raw.githubusercontent.com/aspnet/Home/dev/dnvm.sh
source $DNX_DIR /dnvm.sh
fi
2015-10-19 06:29:51 +00:00
2015-10-20 16:05:17 +00:00
dnvm install latest -u -r coreclr
rc = $? ; if [ [ $rc != 0 ] ] ; then exit $rc ; fi
# Make sure we got a DNX
if ! type dnx > /dev/null 2>& 1; then
echo "DNX is required to bootstrap stage1" 1>& 2
exit 1
fi
2015-10-16 22:30:28 +00:00
fi
2015-10-20 16:05:17 +00:00
echo "Running 'dnu restore' to restore packages"
2015-10-16 22:30:28 +00:00
2015-10-16 22:56:34 +00:00
dnu restore " $REPOROOT " --runtime osx.10.10-x64 --runtime ubuntu.14.04-x64 --runtime osx.10.11-x64
2015-10-20 16:05:17 +00:00
rc = $? ; if [ [ $rc != 0 ] ] ; then exit $rc ; fi
2015-10-18 11:02:58 +00:00
2015-10-16 22:30:28 +00:00
# Clean up stage1
[ -d " $STAGE1_DIR " ] && rm -Rf " $STAGE1_DIR "
2015-10-20 16:05:17 +00:00
echo "Building basic dotnet tools using Stage 0"
dotnet publish --framework dnxcore50 --runtime $RID --output " $STAGE1_DIR " " $REPOROOT /src/Microsoft.DotNet.Cli "
2015-10-18 09:38:46 +00:00
rc = $? ; if [ [ $rc != 0 ] ] ; then exit $rc ; fi
2015-10-20 16:05:17 +00:00
dotnet publish --framework dnxcore50 --runtime $RID --output " $STAGE1_DIR " " $REPOROOT /src/Microsoft.DotNet.Tools.Compiler "
2015-10-18 09:38:46 +00:00
rc = $? ; if [ [ $rc != 0 ] ] ; then exit $rc ; fi
2015-10-20 16:05:17 +00:00
dotnet publish --framework dnxcore50 --runtime $RID --output " $STAGE1_DIR " " $REPOROOT /src/Microsoft.DotNet.Tools.Compiler.Csc "
2015-10-18 09:38:46 +00:00
rc = $? ; if [ [ $rc != 0 ] ] ; then exit $rc ; fi
2015-10-20 16:05:17 +00:00
dotnet publish --framework dnxcore50 --runtime $RID --output " $STAGE1_DIR " " $REPOROOT /src/Microsoft.DotNet.Tools.Publish "
2015-10-19 04:07:48 +00:00
rc = $? ; if [ [ $rc != 0 ] ] ; then exit $rc ; fi
2015-10-20 16:05:17 +00:00
dotnet publish --framework dnxcore50 --runtime $RID --output " $STAGE1_DIR " " $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 :$PATH
2015-10-22 06:41:38 +00:00
# Make corerun explicitly executable
chmod a+x $STAGE1_DIR /corerun
2015-10-16 22:30:28 +00:00
echo "Building stage2 dotnet using stage1 ..."
dotnet publish --framework dnxcore50 --runtime $RID --output " $STAGE2_DIR " " $REPOROOT /src/Microsoft.DotNet.Cli "
2015-10-18 09:38:46 +00:00
rc = $? ; if [ [ $rc != 0 ] ] ; then exit $rc ; fi
2015-10-16 22:30:28 +00:00
dotnet publish --framework dnxcore50 --runtime $RID --output " $STAGE2_DIR " " $REPOROOT /src/Microsoft.DotNet.Tools.Compiler "
2015-10-18 09:38:46 +00:00
rc = $? ; if [ [ $rc != 0 ] ] ; then exit $rc ; fi
2015-10-18 08:17:13 +00:00
dotnet publish --framework dnxcore50 --runtime $RID --output " $STAGE2_DIR " " $REPOROOT /src/Microsoft.DotNet.Tools.Compiler.Csc "
2015-10-18 09:38:46 +00:00
rc = $? ; if [ [ $rc != 0 ] ] ; then exit $rc ; fi
2015-10-16 22:30:28 +00:00
dotnet publish --framework dnxcore50 --runtime $RID --output " $STAGE2_DIR " " $REPOROOT /src/Microsoft.DotNet.Tools.Publish "
2015-10-18 09:38:46 +00:00
rc = $? ; if [ [ $rc != 0 ] ] ; then exit $rc ; fi
2015-10-19 04:07:48 +00:00
dotnet publish --framework dnxcore50 --runtime $RID --output " $STAGE2_DIR " " $REPOROOT /src/Microsoft.DotNet.Tools.Resgen "
rc = $? ; if [ [ $rc != 0 ] ] ; then exit $rc ; fi
2015-10-22 06:41:38 +00:00
# Make Stage 2 Folder Accessible
chmod -R a+r $STAGE2_DIR