From f4f9f314a0d1f3049db8b4924fac152bb7db2171 Mon Sep 17 00:00:00 2001 From: Mike Date: Tue, 12 Feb 2019 16:28:32 -0800 Subject: [PATCH] cleaned up dotnet and t4 checks --- getFNA.sh | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/getFNA.sh b/getFNA.sh index 3a3851c..34abdb6 100755 --- a/getFNA.sh +++ b/getFNA.sh @@ -4,6 +4,27 @@ # Usage: ./getFNA.sh # Description: Quick and easy way to install a local copy of FNA and its native libraries. +# Checks if dotnet is installed +function checkDotnet() +{ + # || { echo >&2 "ERROR: dotnet is not installed. Please install dotnet to download the t4 tool."; exit 1; } + command -v dotnet > /dev/null 2>&1 + if [ ! $? -eq 0 ]; then + echo >&2 "ERROR: dotnet is not installed. Please install dotnet to download the t4 tool." + exit 1 + fi +} + +# Checks if t4 is installed and installs it if it isnt +function installT4() +{ + checkDotnet + command -v t4 > /dev/null 2>&1 + if [ ! $? -eq 0 ]; then + dotnet tool install -g dotnet-t4 + fi +} + # Checks if git is installed function checkGit() { @@ -95,12 +116,18 @@ fi # install t4 engine -dotnet tool install -g dotnet-t4 +installT4 # Rename project +if [ ! -d "$MY_DIR/project_name" ]; then + # old project_name folder already renamed so we are all done here + exit 1 +fi + + read -p "Enter the project name to use for your folder and csproj file or 'exit' to quit: " newProjectName -if [[ $newProjectName = 'exit' ]]; then +if [[ $newProjectName = 'exit' || -z "$newProjectName" ]]; then exit 1 fi