Instantly share code, notes, and snippets.

Embed
What would you like to do?
.NET Core project setup.sh
#!/bin/bash
SCRIPT_DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
DOTNET_ROOT=${SCRIPT_DIR}/.dotnet
BIN_DIR=${SCRIPT_DIR}/bin
DOTNET_INSTALL=${BIN_DIR}/dotnet-install.sh
DOTNET=${DOTNET_ROOT}/dotnet
CAKE=${BIN_DIR}/dotnet-cake
export DOTNET_CLI_TELEMETRY_OPTOUT=1
export DOTNET_ROOT
if [ ! -d ${BIN_DIR} ]; then
echo "Creating ${BIN_DIR}";
mkdir -p ${BIN_DIR}
fi
if [ ! -d ${DOTNET_ROOT} ]; then
echo "Installing .NET Core"
mkdir -p ${DOTNET_ROOT}
wget -q -O ${DOTNET_INSTALL} https://raw.githubusercontent.com/dotnet/cli/master/scripts/obtain/dotnet-install.sh
chmod +x ${DOTNET_INSTALL}
${DOTNET_INSTALL} --channel Current --install-dir ${DOTNET_ROOT}
cd ${BIN_DIR} && ln -s ../.dotnet/dotnet && cd ..
fi
if [ ! -f ${CAKE} ]; then
echo "Installing Cake Build"
${DOTNET} tool install --tool-path=${BIN_DIR} Cake.Tool --version 0.30.0
printf "#!/bin/bash\nexport DOTNET_ROOT=${DOTNET_ROOT}\nSCRIPT_DIR=\$( cd \"\$( dirname \"\${BASH_SOURCE[0]}\" )\" && pwd )\n\${SCRIPT_DIR}/dotnet-cake \"\$@\"" > ${BIN_DIR}/cake
chmod +x ${BIN_DIR}/cake
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment