3 source="${BASH_SOURCE[0]}"
4 scriptroot
="$( cd -P "$
( dirname "$source" )" && pwd )"
6 base_uri
='https://netcorenativeassets.blob.core.windows.net/resource-packages/external'
11 retry_wait_time_seconds
=30
12 global_json_file
="$(dirname "$
(dirname "${scriptroot}")")/global.json"
13 declare -A native_assets
15 .
$scriptroot/native
/common-library.sh
18 lowerI
="$(echo $1 | awk '{print tolower($0)}')"
40 --retrywaittimeseconds)
41 retry_wait_time_seconds
=$2
45 echo "Common settings:"
46 echo " --installdirectory Directory to install native toolset."
47 echo " This is a command-line override for the default"
48 echo " Install directory precedence order:"
49 echo " - InstallDirectory command-line override"
50 echo " - NETCOREENG_INSTALL_DIRECTORY environment variable"
51 echo " - (default) %USERPROFILE%/.netcoreeng/native"
53 echo " --clean Switch specifying not to install anything, but cleanup native asset folders"
54 echo " --force Clean and then install tools"
55 echo " --help Print help and exit"
57 echo "Advanced settings:"
58 echo " --baseuri <value> Base URI for where to download native tools from"
59 echo " --downloadretries <value> Number of times a download should be attempted"
60 echo " --retrywaittimeseconds <value> Wait time between download attempts"
67 function ReadGlobalJsonNativeTools
{
68 # Get the native-tools section from the global.json.
69 local native_tools_section
=$
(cat $global_json_file |
awk '/"native-tools"/,/}/')
70 # Only extract the contents of the object.
71 local native_tools_list
=$
(echo $native_tools_section |
awk -F"[{}]" '{print $2}')
72 native_tools_list
=${native_tools_list//[\" ]/}
73 native_tools_list
=$
( echo "$native_tools_list" |
sed 's/\s//g' |
sed 's/,/\n/g' )
76 while read -r line
; do
77 # Lines are of the form: 'tool:version'
79 while read -r key value
; do
80 native_assets
[$key]=$value
82 done <<< "$native_tools_list"
88 native_base_dir
=$install_directory
89 if [[ -z $install_directory ]]; then
90 native_base_dir
=$
(GetNativeInstallDirectory
)
93 install_bin
="${native_base_dir}/bin"
95 ReadGlobalJsonNativeTools
97 if [[ ${#native_assets[@]} -eq 0 ]]; then
98 echo "No native tools defined in global.json"
101 native_installer_dir
="$scriptroot/native"
102 for tool
in "${!native_assets[@]}"
104 tool_version
=${native_assets[$tool]}
105 installer_name
="install-$tool.sh"
106 installer_command
="$native_installer_dir/$installer_name"
107 installer_command
+=" --baseuri $base_uri"
108 installer_command
+=" --installpath $install_bin"
109 installer_command
+=" --version $tool_version"
110 echo $installer_command
112 if [[ $force = true
]]; then
113 installer_command
+=" --force"
116 if [[ $clean = true
]]; then
117 installer_command
+=" --clean"
122 if [[ $?
!= 0 ]]; then
123 echo "Execution Failed" >&2
129 if [[ $clean = true
]]; then
133 if [[ -d $install_bin ]]; then
134 echo "Native tools are available from $install_bin"
135 echo "##vso[task.prependpath]$install_bin"
137 echo "Native tools install directory does not exist, installation failed" >&2