darc-init.sh 1.6 KB
Newer Older
1 2 3
#!/usr/bin/env bash

source="${BASH_SOURCE[0]}"
K
Krzysztof Wicher 已提交
4
darcVersion="1.1.0-beta.19205.4"
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21

while [[ $# > 0 ]]; do
  opt="$(echo "$1" | awk '{print tolower($0)}')"
  case "$opt" in
    --darcversion)
      darcVersion=$2
      shift
      ;;
    *)
      echo "Invalid argument: $1"
      usage
      exit 1
      ;;
  esac

  shift
done
22 23 24 25 26 27 28 29 30 31 32 33

# resolve $source until the file is no longer a symlink
while [[ -h "$source" ]]; do
  scriptroot="$( cd -P "$( dirname "$source" )" && pwd )"
  source="$(readlink "$source")"
  # if $source was a relative symlink, we need to resolve it relative to the path where the
  # symlink file was located
  [[ $source != /* ]] && source="$scriptroot/$source"
done
scriptroot="$( cd -P "$( dirname "$source" )" && pwd )"
verbosity=m

34
. "$scriptroot/tools.sh"
35

36 37
function InstallDarcCli {
  local darc_cli_package_name="microsoft.dotnet.darc"
38 39 40 41 42 43

  InitializeDotNetCli
  local dotnet_root=$_InitializeDotNetCli

  local uninstall_command=`$dotnet_root/dotnet tool uninstall $darc_cli_package_name -g`
  local tool_list=$($dotnet_root/dotnet tool list -g)
44
  if [[ $tool_list = *$darc_cli_package_name* ]]; then
45
    echo $($dotnet_root/dotnet tool uninstall $darc_cli_package_name -g)
46 47
  fi

48
  local arcadeServicesSource="https://dotnetfeed.blob.core.windows.net/dotnet-arcade/index.json"
49 50 51

  echo "Installing Darc CLI version $toolset_version..."
  echo "You may need to restart your command shell if this is the first dotnet tool you have installed."
52
  echo $($dotnet_root/dotnet tool install $darc_cli_package_name --version $darcVersion --add-source "$arcadeServicesSource" -v $verbosity -g)
53 54 55
}

InstallDarcCli