2018-10-22 05:07:26 +00:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
|
|
source="${BASH_SOURCE[0]}"
|
2019-05-15 12:11:39 +00:00
|
|
|
darcVersion=''
|
2019-11-22 13:41:58 +00:00
|
|
|
versionEndpoint='https://maestro-prod.westus2.cloudapp.azure.com/api/assets/darc-version?api-version=2019-01-16'
|
|
|
|
verbosity='minimal'
|
2019-02-22 13:41:53 +00:00
|
|
|
|
|
|
|
while [[ $# > 0 ]]; do
|
|
|
|
opt="$(echo "$1" | awk '{print tolower($0)}')"
|
|
|
|
case "$opt" in
|
|
|
|
--darcversion)
|
|
|
|
darcVersion=$2
|
|
|
|
shift
|
|
|
|
;;
|
2019-05-15 12:11:39 +00:00
|
|
|
--versionendpoint)
|
|
|
|
versionEndpoint=$2
|
|
|
|
shift
|
|
|
|
;;
|
2019-08-30 12:32:56 +00:00
|
|
|
--verbosity)
|
|
|
|
verbosity=$2
|
|
|
|
shift
|
|
|
|
;;
|
2019-10-24 22:05:36 +00:00
|
|
|
--toolpath)
|
|
|
|
toolpath=$2
|
|
|
|
shift
|
|
|
|
;;
|
2019-02-22 13:41:53 +00:00
|
|
|
*)
|
|
|
|
echo "Invalid argument: $1"
|
|
|
|
usage
|
|
|
|
exit 1
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
shift
|
|
|
|
done
|
2018-10-22 05:07:26 +00:00
|
|
|
|
|
|
|
# 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 )"
|
|
|
|
|
|
|
|
. "$scriptroot/tools.sh"
|
|
|
|
|
2019-05-15 12:11:39 +00:00
|
|
|
if [ -z "$darcVersion" ]; then
|
|
|
|
darcVersion=$(curl -X GET "$versionEndpoint" -H "accept: text/plain")
|
|
|
|
fi
|
|
|
|
|
2018-10-22 05:07:26 +00:00
|
|
|
function InstallDarcCli {
|
|
|
|
local darc_cli_package_name="microsoft.dotnet.darc"
|
2018-12-19 20:55:42 +00:00
|
|
|
|
|
|
|
InitializeDotNetCli
|
|
|
|
local dotnet_root=$_InitializeDotNetCli
|
|
|
|
|
2019-10-24 22:05:36 +00:00
|
|
|
if [ -z "$toolpath" ]; then
|
|
|
|
local tool_list=$($dotnet_root/dotnet tool list -g)
|
|
|
|
if [[ $tool_list = *$darc_cli_package_name* ]]; then
|
|
|
|
echo $($dotnet_root/dotnet tool uninstall $darc_cli_package_name -g)
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
local tool_list=$($dotnet_root/dotnet tool list --tool-path "$toolpath")
|
|
|
|
if [[ $tool_list = *$darc_cli_package_name* ]]; then
|
|
|
|
echo $($dotnet_root/dotnet tool uninstall $darc_cli_package_name --tool-path "$toolpath")
|
|
|
|
fi
|
2018-10-22 05:07:26 +00:00
|
|
|
fi
|
|
|
|
|
2019-10-24 22:05:36 +00:00
|
|
|
local arcadeServicesSource="https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-tools/nuget/v3/index.json"
|
2018-10-22 05:07:26 +00:00
|
|
|
|
2019-05-15 12:11:39 +00:00
|
|
|
echo "Installing Darc CLI version $darcVersion..."
|
2018-10-22 05:07:26 +00:00
|
|
|
echo "You may need to restart your command shell if this is the first dotnet tool you have installed."
|
2019-10-24 22:05:36 +00:00
|
|
|
if [ -z "$toolpath" ]; then
|
|
|
|
echo $($dotnet_root/dotnet tool install $darc_cli_package_name --version $darcVersion --add-source "$arcadeServicesSource" -v $verbosity -g)
|
|
|
|
else
|
|
|
|
echo $($dotnet_root/dotnet tool install $darc_cli_package_name --version $darcVersion --add-source "$arcadeServicesSource" -v $verbosity --tool-path "$toolpath")
|
|
|
|
fi
|
2018-10-22 05:07:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
InstallDarcCli
|