2016-02-02 18:04:50 +00:00
#!/usr/bin/env bash
#
# Copyright (c) .NET Foundation and contributors. All rights reserved.
# Licensed under the MIT license. See LICENSE file in the project root for full license information.
#
set -e
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 ) "
2016-02-18 00:16:25 +00:00
2016-09-15 23:19:33 +00:00
$DIR /scripts/obtain/dotnet-install.sh --channel $CHANNEL --verbose
2016-07-08 00:48:25 +00:00
__init_tools_log = $DIR /init-tools.log
2016-07-12 22:42:27 +00:00
__BUILD_TOOLS_CLI_VERSION = $( cat " $DIR /BuildToolsCliVersion.txt " )
2016-07-08 00:48:25 +00:00
__BUILD_TOOLS_DIR = $DIR /build_tools
2016-07-12 22:42:27 +00:00
__BUILD_TOOLS_CLI_DIR = $__BUILD_TOOLS_DIR /dotnetcli/
2016-07-08 00:48:25 +00:00
__BUILD_TOOLS_SOURCE = https://dotnet.myget.org/F/dotnet-buildtools/api/v3/index.json
__BUILD_TOOLS_PACKAGE_VERSION = $( cat $DIR /BuildToolsVersion.txt)
__BUILD_TOOLS_PATH = $NUGET_PACKAGES /Microsoft.DotNet.BuildTools/$__BUILD_TOOLS_PACKAGE_VERSION /lib
__BUILD_TOOLS_SEMAPHORE = $__BUILD_TOOLS_DIR /init-tools.completed
2016-07-29 04:17:32 +00:00
__DOTNET_CMD = $__BUILD_TOOLS_CLI_DIR /dotnet
2016-07-08 00:48:25 +00:00
__PROJECT_JSON_PATH = $__BUILD_TOOLS_DIR /$__BUILD_TOOLS_PACKAGE_VERSION
__PROJECT_JSON_FILE = $__PROJECT_JSON_PATH /project.json
__PROJECT_JSON_CONTENTS = " { \"dependencies\": { \"Microsoft.DotNet.BuildTools\": \" $__BUILD_TOOLS_PACKAGE_VERSION \" }, \"frameworks\": { \"netcoreapp1.0\": { } } } "
if [ ! -e " $__PROJECT_JSON_FILE " ] ; then
mkdir -p " $__PROJECT_JSON_PATH "
echo " $__PROJECT_JSON_CONTENTS " > " $__PROJECT_JSON_FILE "
2016-07-29 04:43:09 +00:00
if [ ! -d " $__BUILD_TOOLS_CLI_DIR " ] ; then
echo " Installing Build Tools CLI Version: $__BUILD_TOOLS_CLI_VERSION "
" $DIR /scripts/obtain/dotnet-install.sh " --channel rel-1.0.0 --version " $__BUILD_TOOLS_CLI_VERSION " --install-dir " $__BUILD_TOOLS_CLI_DIR "
fi
2016-07-08 00:48:25 +00:00
if [ ! -d " $__BUILD_TOOLS_PATH " ] ; then
echo " Restoring build tools version $__BUILD_TOOLS_PACKAGE_VERSION ... "
2016-07-28 06:40:47 +00:00
" $__DOTNET_CMD " restore " $__PROJECT_JSON_FILE " --packages " $NUGET_PACKAGES " --source " $__BUILD_TOOLS_SOURCE "
2016-07-08 00:48:25 +00:00
2016-07-28 07:01:14 +00:00
if [ ! -e " $__BUILD_TOOLS_PATH /init-tools.sh " ] ; then echo " ERROR: Could not restore build tools correctly. See ' $__init_tools_log ' for more details. " ; fi
find .
2016-07-29 04:43:09 +00:00
fi
2016-07-08 00:48:25 +00:00
echo "Initializing build tools..."
" $__BUILD_TOOLS_PATH /init-tools.sh " " $DIR " " $__DOTNET_CMD " " $__BUILD_TOOLS_DIR " >> " $__init_tools_log " 2>& 1
echo " Init-Tools completed for BuildTools Version: $__BUILD_TOOLS_PACKAGE_VERSION " > " $__BUILD_TOOLS_SEMAPHORE "
echo "Done initializing tools"
else
echo "Tools are already initialized"
fi
2016-07-12 22:42:27 +00:00