dotnet-install.sh 62 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887
  1. #!/usr/bin/env bash
  2. # Copyright (c) .NET Foundation and contributors. All rights reserved.
  3. # Licensed under the MIT license. See LICENSE file in the project root for full license information.
  4. #
  5. # Stop script on NZEC
  6. set -e
  7. # Stop script if unbound variable found (use ${var:-} if intentional)
  8. set -u
  9. # By default cmd1 | cmd2 returns exit code of cmd2 regardless of cmd1 success
  10. # This is causing it to fail
  11. set -o pipefail
  12. # Use in the the functions: eval $invocation
  13. invocation='say_verbose "Calling: ${yellow:-}${FUNCNAME[0]} ${green:-}$*${normal:-}"'
  14. # standard output may be used as a return value in the functions
  15. # we need a way to write text on the screen in the functions so that
  16. # it won't interfere with the return value.
  17. # Exposing stream 3 as a pipe to standard output of the script itself
  18. exec 3>&1
  19. # Setup some colors to use. These need to work in fairly limited shells, like the Ubuntu Docker container where there are only 8 colors.
  20. # See if stdout is a terminal
  21. if [ -t 1 ] && command -v tput > /dev/null; then
  22. # see if it supports colors
  23. ncolors=$(tput colors || echo 0)
  24. if [ -n "$ncolors" ] && [ $ncolors -ge 8 ]; then
  25. bold="$(tput bold || echo)"
  26. normal="$(tput sgr0 || echo)"
  27. black="$(tput setaf 0 || echo)"
  28. red="$(tput setaf 1 || echo)"
  29. green="$(tput setaf 2 || echo)"
  30. yellow="$(tput setaf 3 || echo)"
  31. blue="$(tput setaf 4 || echo)"
  32. magenta="$(tput setaf 5 || echo)"
  33. cyan="$(tput setaf 6 || echo)"
  34. white="$(tput setaf 7 || echo)"
  35. fi
  36. fi
  37. say_warning() {
  38. printf "%b\n" "${yellow:-}dotnet_install: Warning: $1${normal:-}" >&3
  39. }
  40. say_err() {
  41. printf "%b\n" "${red:-}dotnet_install: Error: $1${normal:-}" >&2
  42. }
  43. say() {
  44. # using stream 3 (defined in the beginning) to not interfere with stdout of functions
  45. # which may be used as return value
  46. printf "%b\n" "${cyan:-}dotnet-install:${normal:-} $1" >&3
  47. }
  48. say_verbose() {
  49. if [ "$verbose" = true ]; then
  50. say "$1"
  51. fi
  52. }
  53. # This platform list is finite - if the SDK/Runtime has supported Linux distribution-specific assets,
  54. # then and only then should the Linux distribution appear in this list.
  55. # Adding a Linux distribution to this list does not imply distribution-specific support.
  56. get_legacy_os_name_from_platform() {
  57. eval $invocation
  58. platform="$1"
  59. case "$platform" in
  60. "centos.7")
  61. echo "centos"
  62. return 0
  63. ;;
  64. "debian.8")
  65. echo "debian"
  66. return 0
  67. ;;
  68. "debian.9")
  69. echo "debian.9"
  70. return 0
  71. ;;
  72. "fedora.23")
  73. echo "fedora.23"
  74. return 0
  75. ;;
  76. "fedora.24")
  77. echo "fedora.24"
  78. return 0
  79. ;;
  80. "fedora.27")
  81. echo "fedora.27"
  82. return 0
  83. ;;
  84. "fedora.28")
  85. echo "fedora.28"
  86. return 0
  87. ;;
  88. "opensuse.13.2")
  89. echo "opensuse.13.2"
  90. return 0
  91. ;;
  92. "opensuse.42.1")
  93. echo "opensuse.42.1"
  94. return 0
  95. ;;
  96. "opensuse.42.3")
  97. echo "opensuse.42.3"
  98. return 0
  99. ;;
  100. "rhel.7"*)
  101. echo "rhel"
  102. return 0
  103. ;;
  104. "ubuntu.14.04")
  105. echo "ubuntu"
  106. return 0
  107. ;;
  108. "ubuntu.16.04")
  109. echo "ubuntu.16.04"
  110. return 0
  111. ;;
  112. "ubuntu.16.10")
  113. echo "ubuntu.16.10"
  114. return 0
  115. ;;
  116. "ubuntu.18.04")
  117. echo "ubuntu.18.04"
  118. return 0
  119. ;;
  120. "alpine.3.4.3")
  121. echo "alpine"
  122. return 0
  123. ;;
  124. esac
  125. return 1
  126. }
  127. get_legacy_os_name() {
  128. eval $invocation
  129. local uname=$(uname)
  130. if [ "$uname" = "Darwin" ]; then
  131. echo "osx"
  132. return 0
  133. elif [ -n "$runtime_id" ]; then
  134. echo $(get_legacy_os_name_from_platform "${runtime_id%-*}" || echo "${runtime_id%-*}")
  135. return 0
  136. else
  137. if [ -e /etc/os-release ]; then
  138. . /etc/os-release
  139. os=$(get_legacy_os_name_from_platform "$ID${VERSION_ID:+.${VERSION_ID}}" || echo "")
  140. if [ -n "$os" ]; then
  141. echo "$os"
  142. return 0
  143. fi
  144. fi
  145. fi
  146. say_verbose "Distribution specific OS name and version could not be detected: UName = $uname"
  147. return 1
  148. }
  149. get_linux_platform_name() {
  150. eval $invocation
  151. if [ -n "$runtime_id" ]; then
  152. echo "${runtime_id%-*}"
  153. return 0
  154. else
  155. if [ -e /etc/os-release ]; then
  156. . /etc/os-release
  157. echo "$ID${VERSION_ID:+.${VERSION_ID}}"
  158. return 0
  159. elif [ -e /etc/redhat-release ]; then
  160. local redhatRelease=$(</etc/redhat-release)
  161. if [[ $redhatRelease == "CentOS release 6."* || $redhatRelease == "Red Hat Enterprise Linux "*" release 6."* ]]; then
  162. echo "rhel.6"
  163. return 0
  164. fi
  165. fi
  166. fi
  167. say_verbose "Linux specific platform name and version could not be detected: UName = $uname"
  168. return 1
  169. }
  170. is_musl_based_distro() {
  171. (ldd --version 2>&1 || true) | grep -q musl
  172. }
  173. get_current_os_name() {
  174. eval $invocation
  175. local uname=$(uname)
  176. if [ "$uname" = "Darwin" ]; then
  177. echo "osx"
  178. return 0
  179. elif [ "$uname" = "FreeBSD" ]; then
  180. echo "freebsd"
  181. return 0
  182. elif [ "$uname" = "Linux" ]; then
  183. local linux_platform_name=""
  184. linux_platform_name="$(get_linux_platform_name)" || true
  185. if [ "$linux_platform_name" = "rhel.6" ]; then
  186. echo $linux_platform_name
  187. return 0
  188. elif is_musl_based_distro; then
  189. echo "linux-musl"
  190. return 0
  191. elif [ "$linux_platform_name" = "linux-musl" ]; then
  192. echo "linux-musl"
  193. return 0
  194. else
  195. echo "linux"
  196. return 0
  197. fi
  198. fi
  199. say_err "OS name could not be detected: UName = $uname"
  200. return 1
  201. }
  202. machine_has() {
  203. eval $invocation
  204. command -v "$1" > /dev/null 2>&1
  205. return $?
  206. }
  207. check_min_reqs() {
  208. local hasMinimum=false
  209. if machine_has "curl"; then
  210. hasMinimum=true
  211. elif machine_has "wget"; then
  212. hasMinimum=true
  213. fi
  214. if [ "$hasMinimum" = "false" ]; then
  215. say_err "curl (recommended) or wget are required to download dotnet. Install missing prerequisite to proceed."
  216. return 1
  217. fi
  218. return 0
  219. }
  220. # args:
  221. # input - $1
  222. to_lowercase() {
  223. #eval $invocation
  224. echo "$1" | tr '[:upper:]' '[:lower:]'
  225. return 0
  226. }
  227. # args:
  228. # input - $1
  229. remove_trailing_slash() {
  230. #eval $invocation
  231. local input="${1:-}"
  232. echo "${input%/}"
  233. return 0
  234. }
  235. # args:
  236. # input - $1
  237. remove_beginning_slash() {
  238. #eval $invocation
  239. local input="${1:-}"
  240. echo "${input#/}"
  241. return 0
  242. }
  243. # args:
  244. # root_path - $1
  245. # child_path - $2 - this parameter can be empty
  246. combine_paths() {
  247. eval $invocation
  248. # TODO: Consider making it work with any number of paths. For now:
  249. if [ ! -z "${3:-}" ]; then
  250. say_err "combine_paths: Function takes two parameters."
  251. return 1
  252. fi
  253. local root_path="$(remove_trailing_slash "$1")"
  254. local child_path="$(remove_beginning_slash "${2:-}")"
  255. say_verbose "combine_paths: root_path=$root_path"
  256. say_verbose "combine_paths: child_path=$child_path"
  257. echo "$root_path/$child_path"
  258. return 0
  259. }
  260. get_machine_architecture() {
  261. eval $invocation
  262. if command -v uname > /dev/null; then
  263. CPUName=$(uname -m)
  264. case $CPUName in
  265. armv1*|armv2*|armv3*|armv4*|armv5*|armv6*)
  266. echo "armv6-or-below"
  267. return 0
  268. ;;
  269. armv*l)
  270. echo "arm"
  271. return 0
  272. ;;
  273. aarch64|arm64)
  274. if [ "$(getconf LONG_BIT)" -lt 64 ]; then
  275. # This is 32-bit OS running on 64-bit CPU (for example Raspberry Pi OS)
  276. echo "arm"
  277. return 0
  278. fi
  279. echo "arm64"
  280. return 0
  281. ;;
  282. s390x)
  283. echo "s390x"
  284. return 0
  285. ;;
  286. ppc64le)
  287. echo "ppc64le"
  288. return 0
  289. ;;
  290. loongarch64)
  291. echo "loongarch64"
  292. return 0
  293. ;;
  294. riscv64)
  295. echo "riscv64"
  296. return 0
  297. ;;
  298. powerpc|ppc)
  299. echo "ppc"
  300. return 0
  301. ;;
  302. esac
  303. fi
  304. # Always default to 'x64'
  305. echo "x64"
  306. return 0
  307. }
  308. # args:
  309. # architecture - $1
  310. get_normalized_architecture_from_architecture() {
  311. eval $invocation
  312. local architecture="$(to_lowercase "$1")"
  313. if [[ $architecture == \<auto\> ]]; then
  314. machine_architecture="$(get_machine_architecture)"
  315. if [[ "$machine_architecture" == "armv6-or-below" ]]; then
  316. say_err "Architecture \`$machine_architecture\` not supported. If you think this is a bug, report it at https://github.com/dotnet/install-scripts/issues"
  317. return 1
  318. fi
  319. echo $machine_architecture
  320. return 0
  321. fi
  322. case "$architecture" in
  323. amd64|x64)
  324. echo "x64"
  325. return 0
  326. ;;
  327. arm)
  328. echo "arm"
  329. return 0
  330. ;;
  331. arm64)
  332. echo "arm64"
  333. return 0
  334. ;;
  335. s390x)
  336. echo "s390x"
  337. return 0
  338. ;;
  339. ppc64le)
  340. echo "ppc64le"
  341. return 0
  342. ;;
  343. loongarch64)
  344. echo "loongarch64"
  345. return 0
  346. ;;
  347. esac
  348. say_err "Architecture \`$architecture\` not supported. If you think this is a bug, report it at https://github.com/dotnet/install-scripts/issues"
  349. return 1
  350. }
  351. # args:
  352. # version - $1
  353. # channel - $2
  354. # architecture - $3
  355. get_normalized_architecture_for_specific_sdk_version() {
  356. eval $invocation
  357. local is_version_support_arm64="$(is_arm64_supported "$1")"
  358. local is_channel_support_arm64="$(is_arm64_supported "$2")"
  359. local architecture="$3";
  360. local osname="$(get_current_os_name)"
  361. if [ "$osname" == "osx" ] && [ "$architecture" == "arm64" ] && { [ "$is_version_support_arm64" = false ] || [ "$is_channel_support_arm64" = false ]; }; then
  362. #check if rosetta is installed
  363. if [ "$(/usr/bin/pgrep oahd >/dev/null 2>&1;echo $?)" -eq 0 ]; then
  364. say_verbose "Changing user architecture from '$architecture' to 'x64' because .NET SDKs prior to version 6.0 do not support arm64."
  365. echo "x64"
  366. return 0;
  367. else
  368. say_err "Architecture \`$architecture\` is not supported for .NET SDK version \`$version\`. Please install Rosetta to allow emulation of the \`$architecture\` .NET SDK on this platform"
  369. return 1
  370. fi
  371. fi
  372. echo "$architecture"
  373. return 0
  374. }
  375. # args:
  376. # version or channel - $1
  377. is_arm64_supported() {
  378. # Extract the major version by splitting on the dot
  379. major_version="${1%%.*}"
  380. # Check if the major version is a valid number and less than 6
  381. case "$major_version" in
  382. [0-9]*)
  383. if [ "$major_version" -lt 6 ]; then
  384. echo false
  385. return 0
  386. fi
  387. ;;
  388. esac
  389. echo true
  390. return 0
  391. }
  392. # args:
  393. # user_defined_os - $1
  394. get_normalized_os() {
  395. eval $invocation
  396. local osname="$(to_lowercase "$1")"
  397. if [ ! -z "$osname" ]; then
  398. case "$osname" in
  399. osx | freebsd | rhel.6 | linux-musl | linux)
  400. echo "$osname"
  401. return 0
  402. ;;
  403. macos)
  404. osname='osx'
  405. echo "$osname"
  406. return 0
  407. ;;
  408. *)
  409. say_err "'$user_defined_os' is not a supported value for --os option, supported values are: osx, macos, linux, linux-musl, freebsd, rhel.6. If you think this is a bug, report it at https://github.com/dotnet/install-scripts/issues."
  410. return 1
  411. ;;
  412. esac
  413. else
  414. osname="$(get_current_os_name)" || return 1
  415. fi
  416. echo "$osname"
  417. return 0
  418. }
  419. # args:
  420. # quality - $1
  421. get_normalized_quality() {
  422. eval $invocation
  423. local quality="$(to_lowercase "$1")"
  424. if [ ! -z "$quality" ]; then
  425. case "$quality" in
  426. daily | preview)
  427. echo "$quality"
  428. return 0
  429. ;;
  430. ga)
  431. #ga quality is available without specifying quality, so normalizing it to empty
  432. return 0
  433. ;;
  434. *)
  435. say_err "'$quality' is not a supported value for --quality option. Supported values are: daily, preview, ga. If you think this is a bug, report it at https://github.com/dotnet/install-scripts/issues."
  436. return 1
  437. ;;
  438. esac
  439. fi
  440. return 0
  441. }
  442. # args:
  443. # channel - $1
  444. get_normalized_channel() {
  445. eval $invocation
  446. local channel="$(to_lowercase "$1")"
  447. if [[ $channel == current ]]; then
  448. say_warning 'Value "Current" is deprecated for -Channel option. Use "STS" instead.'
  449. fi
  450. if [[ $channel == release/* ]]; then
  451. say_warning 'Using branch name with -Channel option is no longer supported with newer releases. Use -Quality option with a channel in X.Y format instead.';
  452. fi
  453. if [ ! -z "$channel" ]; then
  454. case "$channel" in
  455. lts)
  456. echo "LTS"
  457. return 0
  458. ;;
  459. sts)
  460. echo "STS"
  461. return 0
  462. ;;
  463. current)
  464. echo "STS"
  465. return 0
  466. ;;
  467. *)
  468. echo "$channel"
  469. return 0
  470. ;;
  471. esac
  472. fi
  473. return 0
  474. }
  475. # args:
  476. # runtime - $1
  477. get_normalized_product() {
  478. eval $invocation
  479. local product=""
  480. local runtime="$(to_lowercase "$1")"
  481. if [[ "$runtime" == "dotnet" ]]; then
  482. product="dotnet-runtime"
  483. elif [[ "$runtime" == "aspnetcore" ]]; then
  484. product="aspnetcore-runtime"
  485. elif [ -z "$runtime" ]; then
  486. product="dotnet-sdk"
  487. fi
  488. echo "$product"
  489. return 0
  490. }
  491. # The version text returned from the feeds is a 1-line or 2-line string:
  492. # For the SDK and the dotnet runtime (2 lines):
  493. # Line 1: # commit_hash
  494. # Line 2: # 4-part version
  495. # For the aspnetcore runtime (1 line):
  496. # Line 1: # 4-part version
  497. # args:
  498. # version_text - stdin
  499. get_version_from_latestversion_file_content() {
  500. eval $invocation
  501. cat | tail -n 1 | sed 's/\r$//'
  502. return 0
  503. }
  504. # args:
  505. # install_root - $1
  506. # relative_path_to_package - $2
  507. # specific_version - $3
  508. is_dotnet_package_installed() {
  509. eval $invocation
  510. local install_root="$1"
  511. local relative_path_to_package="$2"
  512. local specific_version="${3//[$'\t\r\n']}"
  513. local dotnet_package_path="$(combine_paths "$(combine_paths "$install_root" "$relative_path_to_package")" "$specific_version")"
  514. say_verbose "is_dotnet_package_installed: dotnet_package_path=$dotnet_package_path"
  515. if [ -d "$dotnet_package_path" ]; then
  516. return 0
  517. else
  518. return 1
  519. fi
  520. }
  521. # args:
  522. # downloaded file - $1
  523. # remote_file_size - $2
  524. validate_remote_local_file_sizes()
  525. {
  526. eval $invocation
  527. local downloaded_file="$1"
  528. local remote_file_size="$2"
  529. local file_size=''
  530. if [[ "$OSTYPE" == "linux-gnu"* ]]; then
  531. file_size="$(stat -c '%s' "$downloaded_file")"
  532. elif [[ "$OSTYPE" == "darwin"* ]]; then
  533. # hardcode in order to avoid conflicts with GNU stat
  534. file_size="$(/usr/bin/stat -f '%z' "$downloaded_file")"
  535. fi
  536. if [ -n "$file_size" ]; then
  537. say "Downloaded file size is $file_size bytes."
  538. if [ -n "$remote_file_size" ] && [ -n "$file_size" ]; then
  539. if [ "$remote_file_size" -ne "$file_size" ]; then
  540. say "The remote and local file sizes are not equal. The remote file size is $remote_file_size bytes and the local size is $file_size bytes. The local package may be corrupted."
  541. else
  542. say "The remote and local file sizes are equal."
  543. fi
  544. fi
  545. else
  546. say "Either downloaded or local package size can not be measured. One of them may be corrupted."
  547. fi
  548. }
  549. # args:
  550. # azure_feed - $1
  551. # channel - $2
  552. # normalized_architecture - $3
  553. get_version_from_latestversion_file() {
  554. eval $invocation
  555. local azure_feed="$1"
  556. local channel="$2"
  557. local normalized_architecture="$3"
  558. local version_file_url=null
  559. if [[ "$runtime" == "dotnet" ]]; then
  560. version_file_url="$azure_feed/Runtime/$channel/latest.version"
  561. elif [[ "$runtime" == "aspnetcore" ]]; then
  562. version_file_url="$azure_feed/aspnetcore/Runtime/$channel/latest.version"
  563. elif [ -z "$runtime" ]; then
  564. version_file_url="$azure_feed/Sdk/$channel/latest.version"
  565. else
  566. say_err "Invalid value for \$runtime"
  567. return 1
  568. fi
  569. say_verbose "get_version_from_latestversion_file: latest url: $version_file_url"
  570. download "$version_file_url" || return $?
  571. return 0
  572. }
  573. # args:
  574. # json_file - $1
  575. parse_globaljson_file_for_version() {
  576. eval $invocation
  577. local json_file="$1"
  578. if [ ! -f "$json_file" ]; then
  579. say_err "Unable to find \`$json_file\`"
  580. return 1
  581. fi
  582. sdk_section=$(cat "$json_file" | tr -d "\r" | awk '/"sdk"/,/}/')
  583. if [ -z "$sdk_section" ]; then
  584. say_err "Unable to parse the SDK node in \`$json_file\`"
  585. return 1
  586. fi
  587. sdk_list=$(echo $sdk_section | awk -F"[{}]" '{print $2}')
  588. sdk_list=${sdk_list//[\" ]/}
  589. sdk_list=${sdk_list//,/$'\n'}
  590. local version_info=""
  591. while read -r line; do
  592. IFS=:
  593. while read -r key value; do
  594. if [[ "$key" == "version" ]]; then
  595. version_info=$value
  596. fi
  597. done <<< "$line"
  598. done <<< "$sdk_list"
  599. if [ -z "$version_info" ]; then
  600. say_err "Unable to find the SDK:version node in \`$json_file\`"
  601. return 1
  602. fi
  603. unset IFS;
  604. echo "$version_info"
  605. return 0
  606. }
  607. # args:
  608. # azure_feed - $1
  609. # channel - $2
  610. # normalized_architecture - $3
  611. # version - $4
  612. # json_file - $5
  613. get_specific_version_from_version() {
  614. eval $invocation
  615. local azure_feed="$1"
  616. local channel="$2"
  617. local normalized_architecture="$3"
  618. local version="$(to_lowercase "$4")"
  619. local json_file="$5"
  620. if [ -z "$json_file" ]; then
  621. if [[ "$version" == "latest" ]]; then
  622. local version_info
  623. version_info="$(get_version_from_latestversion_file "$azure_feed" "$channel" "$normalized_architecture" false)" || return 1
  624. say_verbose "get_specific_version_from_version: version_info=$version_info"
  625. echo "$version_info" | get_version_from_latestversion_file_content
  626. return 0
  627. else
  628. echo "$version"
  629. return 0
  630. fi
  631. else
  632. local version_info
  633. version_info="$(parse_globaljson_file_for_version "$json_file")" || return 1
  634. echo "$version_info"
  635. return 0
  636. fi
  637. }
  638. # args:
  639. # azure_feed - $1
  640. # channel - $2
  641. # normalized_architecture - $3
  642. # specific_version - $4
  643. # normalized_os - $5
  644. construct_download_link() {
  645. eval $invocation
  646. local azure_feed="$1"
  647. local channel="$2"
  648. local normalized_architecture="$3"
  649. local specific_version="${4//[$'\t\r\n']}"
  650. local specific_product_version="$(get_specific_product_version "$1" "$4")"
  651. local osname="$5"
  652. local download_link=null
  653. if [[ "$runtime" == "dotnet" ]]; then
  654. download_link="$azure_feed/Runtime/$specific_version/dotnet-runtime-$specific_product_version-$osname-$normalized_architecture.tar.gz"
  655. elif [[ "$runtime" == "aspnetcore" ]]; then
  656. download_link="$azure_feed/aspnetcore/Runtime/$specific_version/aspnetcore-runtime-$specific_product_version-$osname-$normalized_architecture.tar.gz"
  657. elif [ -z "$runtime" ]; then
  658. download_link="$azure_feed/Sdk/$specific_version/dotnet-sdk-$specific_product_version-$osname-$normalized_architecture.tar.gz"
  659. else
  660. return 1
  661. fi
  662. echo "$download_link"
  663. return 0
  664. }
  665. # args:
  666. # azure_feed - $1
  667. # specific_version - $2
  668. # download link - $3 (optional)
  669. get_specific_product_version() {
  670. # If we find a 'productVersion.txt' at the root of any folder, we'll use its contents
  671. # to resolve the version of what's in the folder, superseding the specified version.
  672. # if 'productVersion.txt' is missing but download link is already available, product version will be taken from download link
  673. eval $invocation
  674. local azure_feed="$1"
  675. local specific_version="${2//[$'\t\r\n']}"
  676. local package_download_link=""
  677. if [ $# -gt 2 ]; then
  678. local package_download_link="$3"
  679. fi
  680. local specific_product_version=null
  681. # Try to get the version number, using the productVersion.txt file located next to the installer file.
  682. local download_links=($(get_specific_product_version_url "$azure_feed" "$specific_version" true "$package_download_link")
  683. $(get_specific_product_version_url "$azure_feed" "$specific_version" false "$package_download_link"))
  684. for download_link in "${download_links[@]}"
  685. do
  686. say_verbose "Checking for the existence of $download_link"
  687. if machine_has "curl"
  688. then
  689. if ! specific_product_version=$(curl -sL --fail "${download_link}${feed_credential}" 2>&1); then
  690. continue
  691. else
  692. echo "${specific_product_version//[$'\t\r\n']}"
  693. return 0
  694. fi
  695. elif machine_has "wget"
  696. then
  697. specific_product_version=$(wget -qO- "${download_link}${feed_credential}" 2>&1)
  698. if [ $? = 0 ]; then
  699. echo "${specific_product_version//[$'\t\r\n']}"
  700. return 0
  701. fi
  702. fi
  703. done
  704. # Getting the version number with productVersion.txt has failed. Try parsing the download link for a version number.
  705. say_verbose "Failed to get the version using productVersion.txt file. Download link will be parsed instead."
  706. specific_product_version="$(get_product_specific_version_from_download_link "$package_download_link" "$specific_version")"
  707. echo "${specific_product_version//[$'\t\r\n']}"
  708. return 0
  709. }
  710. # args:
  711. # azure_feed - $1
  712. # specific_version - $2
  713. # is_flattened - $3
  714. # download link - $4 (optional)
  715. get_specific_product_version_url() {
  716. eval $invocation
  717. local azure_feed="$1"
  718. local specific_version="$2"
  719. local is_flattened="$3"
  720. local package_download_link=""
  721. if [ $# -gt 3 ]; then
  722. local package_download_link="$4"
  723. fi
  724. local pvFileName="productVersion.txt"
  725. if [ "$is_flattened" = true ]; then
  726. if [ -z "$runtime" ]; then
  727. pvFileName="sdk-productVersion.txt"
  728. elif [[ "$runtime" == "dotnet" ]]; then
  729. pvFileName="runtime-productVersion.txt"
  730. else
  731. pvFileName="$runtime-productVersion.txt"
  732. fi
  733. fi
  734. local download_link=null
  735. if [ -z "$package_download_link" ]; then
  736. if [[ "$runtime" == "dotnet" ]]; then
  737. download_link="$azure_feed/Runtime/$specific_version/${pvFileName}"
  738. elif [[ "$runtime" == "aspnetcore" ]]; then
  739. download_link="$azure_feed/aspnetcore/Runtime/$specific_version/${pvFileName}"
  740. elif [ -z "$runtime" ]; then
  741. download_link="$azure_feed/Sdk/$specific_version/${pvFileName}"
  742. else
  743. return 1
  744. fi
  745. else
  746. download_link="${package_download_link%/*}/${pvFileName}"
  747. fi
  748. say_verbose "Constructed productVersion link: $download_link"
  749. echo "$download_link"
  750. return 0
  751. }
  752. # args:
  753. # download link - $1
  754. # specific version - $2
  755. get_product_specific_version_from_download_link()
  756. {
  757. eval $invocation
  758. local download_link="$1"
  759. local specific_version="$2"
  760. local specific_product_version=""
  761. if [ -z "$download_link" ]; then
  762. echo "$specific_version"
  763. return 0
  764. fi
  765. #get filename
  766. filename="${download_link##*/}"
  767. #product specific version follows the product name
  768. #for filename 'dotnet-sdk-3.1.404-linux-x64.tar.gz': the product version is 3.1.404
  769. IFS='-'
  770. read -ra filename_elems <<< "$filename"
  771. count=${#filename_elems[@]}
  772. if [[ "$count" -gt 2 ]]; then
  773. specific_product_version="${filename_elems[2]}"
  774. else
  775. specific_product_version=$specific_version
  776. fi
  777. unset IFS;
  778. echo "$specific_product_version"
  779. return 0
  780. }
  781. # args:
  782. # azure_feed - $1
  783. # channel - $2
  784. # normalized_architecture - $3
  785. # specific_version - $4
  786. construct_legacy_download_link() {
  787. eval $invocation
  788. local azure_feed="$1"
  789. local channel="$2"
  790. local normalized_architecture="$3"
  791. local specific_version="${4//[$'\t\r\n']}"
  792. local distro_specific_osname
  793. distro_specific_osname="$(get_legacy_os_name)" || return 1
  794. local legacy_download_link=null
  795. if [[ "$runtime" == "dotnet" ]]; then
  796. legacy_download_link="$azure_feed/Runtime/$specific_version/dotnet-$distro_specific_osname-$normalized_architecture.$specific_version.tar.gz"
  797. elif [ -z "$runtime" ]; then
  798. legacy_download_link="$azure_feed/Sdk/$specific_version/dotnet-dev-$distro_specific_osname-$normalized_architecture.$specific_version.tar.gz"
  799. else
  800. return 1
  801. fi
  802. echo "$legacy_download_link"
  803. return 0
  804. }
  805. get_user_install_path() {
  806. eval $invocation
  807. if [ ! -z "${DOTNET_INSTALL_DIR:-}" ]; then
  808. echo "$DOTNET_INSTALL_DIR"
  809. else
  810. echo "$HOME/.dotnet"
  811. fi
  812. return 0
  813. }
  814. # args:
  815. # install_dir - $1
  816. resolve_installation_path() {
  817. eval $invocation
  818. local install_dir=$1
  819. if [ "$install_dir" = "<auto>" ]; then
  820. local user_install_path="$(get_user_install_path)"
  821. say_verbose "resolve_installation_path: user_install_path=$user_install_path"
  822. echo "$user_install_path"
  823. return 0
  824. fi
  825. echo "$install_dir"
  826. return 0
  827. }
  828. # args:
  829. # relative_or_absolute_path - $1
  830. get_absolute_path() {
  831. eval $invocation
  832. local relative_or_absolute_path=$1
  833. echo "$(cd "$(dirname "$1")" && pwd -P)/$(basename "$1")"
  834. return 0
  835. }
  836. # args:
  837. # override - $1 (boolean, true or false)
  838. get_cp_options() {
  839. eval $invocation
  840. local override="$1"
  841. local override_switch=""
  842. if [ "$override" = false ]; then
  843. override_switch="-n"
  844. # create temporary files to check if 'cp -u' is supported
  845. tmp_dir="$(mktemp -d)"
  846. tmp_file="$tmp_dir/testfile"
  847. tmp_file2="$tmp_dir/testfile2"
  848. touch "$tmp_file"
  849. # use -u instead of -n if it's available
  850. if cp -u "$tmp_file" "$tmp_file2" 2>/dev/null; then
  851. override_switch="-u"
  852. fi
  853. # clean up
  854. rm -f "$tmp_file" "$tmp_file2"
  855. rm -rf "$tmp_dir"
  856. fi
  857. echo "$override_switch"
  858. }
  859. # args:
  860. # input_files - stdin
  861. # root_path - $1
  862. # out_path - $2
  863. # override - $3
  864. copy_files_or_dirs_from_list() {
  865. eval $invocation
  866. local root_path="$(remove_trailing_slash "$1")"
  867. local out_path="$(remove_trailing_slash "$2")"
  868. local override="$3"
  869. local override_switch="$(get_cp_options "$override")"
  870. cat | uniq | while read -r file_path; do
  871. local path="$(remove_beginning_slash "${file_path#$root_path}")"
  872. local target="$out_path/$path"
  873. if [ "$override" = true ] || (! ([ -d "$target" ] || [ -e "$target" ] || [ -L "$target" ])); then
  874. mkdir -p "$out_path/$(dirname "$path")"
  875. if [ -d "$target" ] || [ -L "$target" ]; then
  876. rm -rf "$target"
  877. fi
  878. cp -RP $override_switch "$root_path/$path" "$target"
  879. fi
  880. done
  881. }
  882. # args:
  883. # zip_uri - $1
  884. get_remote_file_size() {
  885. local zip_uri="$1"
  886. if machine_has "curl"; then
  887. file_size=$(curl -sI "$zip_uri" | grep -i content-length | awk '{ num = $2 + 0; print num }')
  888. elif machine_has "wget"; then
  889. file_size=$(wget --spider --server-response -O /dev/null "$zip_uri" 2>&1 | grep -i 'Content-Length:' | awk '{ num = $2 + 0; print num }')
  890. else
  891. say "Neither curl nor wget is available on this system."
  892. return
  893. fi
  894. if [ -n "$file_size" ]; then
  895. say "Remote file $zip_uri size is $file_size bytes."
  896. echo "$file_size"
  897. else
  898. say_verbose "Content-Length header was not extracted for $zip_uri."
  899. echo ""
  900. fi
  901. }
  902. # args:
  903. # zip_path - $1
  904. # out_path - $2
  905. # remote_file_size - $3
  906. extract_dotnet_package() {
  907. eval $invocation
  908. local zip_path="$1"
  909. local out_path="$2"
  910. local remote_file_size="$3"
  911. local temp_out_path="$(mktemp -d "$temporary_file_template")"
  912. local failed=false
  913. tar -xzf "$zip_path" -C "$temp_out_path" > /dev/null || failed=true
  914. local folders_with_version_regex='^.*/[0-9]+\.[0-9]+[^/]+/'
  915. find "$temp_out_path" \( -type f -o -type l \) | grep -Eo "$folders_with_version_regex" | sort | copy_files_or_dirs_from_list "$temp_out_path" "$out_path" false
  916. find "$temp_out_path" \( -type f -o -type l \) | grep -Ev "$folders_with_version_regex" | copy_files_or_dirs_from_list "$temp_out_path" "$out_path" "$override_non_versioned_files"
  917. validate_remote_local_file_sizes "$zip_path" "$remote_file_size"
  918. rm -rf "$temp_out_path"
  919. if [ -z ${keep_zip+x} ]; then
  920. rm -f "$zip_path" && say_verbose "Temporary archive file $zip_path was removed"
  921. fi
  922. if [ "$failed" = true ]; then
  923. say_err "Extraction failed"
  924. return 1
  925. fi
  926. return 0
  927. }
  928. # args:
  929. # remote_path - $1
  930. # disable_feed_credential - $2
  931. get_http_header()
  932. {
  933. eval $invocation
  934. local remote_path="$1"
  935. local disable_feed_credential="$2"
  936. local failed=false
  937. local response
  938. if machine_has "curl"; then
  939. get_http_header_curl $remote_path $disable_feed_credential || failed=true
  940. elif machine_has "wget"; then
  941. get_http_header_wget $remote_path $disable_feed_credential || failed=true
  942. else
  943. failed=true
  944. fi
  945. if [ "$failed" = true ]; then
  946. say_verbose "Failed to get HTTP header: '$remote_path'."
  947. return 1
  948. fi
  949. return 0
  950. }
  951. # args:
  952. # remote_path - $1
  953. # disable_feed_credential - $2
  954. get_http_header_curl() {
  955. eval $invocation
  956. local remote_path="$1"
  957. local disable_feed_credential="$2"
  958. remote_path_with_credential="$remote_path"
  959. if [ "$disable_feed_credential" = false ]; then
  960. remote_path_with_credential+="$feed_credential"
  961. fi
  962. curl_options="-I -sSL --retry 5 --retry-delay 2 --connect-timeout 15 "
  963. curl $curl_options "$remote_path_with_credential" 2>&1 || return 1
  964. return 0
  965. }
  966. # args:
  967. # remote_path - $1
  968. # disable_feed_credential - $2
  969. get_http_header_wget() {
  970. eval $invocation
  971. local remote_path="$1"
  972. local disable_feed_credential="$2"
  973. local wget_options="-q -S --spider --tries 5 "
  974. local wget_options_extra=''
  975. # Test for options that aren't supported on all wget implementations.
  976. if [[ $(wget -h 2>&1 | grep -E 'waitretry|connect-timeout') ]]; then
  977. wget_options_extra="--waitretry 2 --connect-timeout 15 "
  978. else
  979. say "wget extra options are unavailable for this environment"
  980. fi
  981. remote_path_with_credential="$remote_path"
  982. if [ "$disable_feed_credential" = false ]; then
  983. remote_path_with_credential+="$feed_credential"
  984. fi
  985. wget $wget_options $wget_options_extra "$remote_path_with_credential" 2>&1
  986. return $?
  987. }
  988. # args:
  989. # remote_path - $1
  990. # [out_path] - $2 - stdout if not provided
  991. download() {
  992. eval $invocation
  993. local remote_path="$1"
  994. local out_path="${2:-}"
  995. if [[ "$remote_path" != "http"* ]]; then
  996. cp "$remote_path" "$out_path"
  997. return $?
  998. fi
  999. local failed=false
  1000. local attempts=0
  1001. while [ $attempts -lt 3 ]; do
  1002. attempts=$((attempts+1))
  1003. failed=false
  1004. if machine_has "curl"; then
  1005. downloadcurl "$remote_path" "$out_path" || failed=true
  1006. elif machine_has "wget"; then
  1007. downloadwget "$remote_path" "$out_path" || failed=true
  1008. else
  1009. say_err "Missing dependency: neither curl nor wget was found."
  1010. exit 1
  1011. fi
  1012. if [ "$failed" = false ] || [ $attempts -ge 3 ] || { [ -n "${http_code-}" ] && [ "${http_code}" = "404" ]; }; then
  1013. break
  1014. fi
  1015. say "Download attempt #$attempts has failed: ${http_code-} ${download_error_msg-}"
  1016. say "Attempt #$((attempts+1)) will start in $((attempts*10)) seconds."
  1017. sleep $((attempts*10))
  1018. done
  1019. if [ "$failed" = true ]; then
  1020. say_verbose "Download failed: $remote_path"
  1021. return 1
  1022. fi
  1023. return 0
  1024. }
  1025. # Updates global variables $http_code and $download_error_msg
  1026. downloadcurl() {
  1027. eval $invocation
  1028. unset http_code
  1029. unset download_error_msg
  1030. local remote_path="$1"
  1031. local out_path="${2:-}"
  1032. # Append feed_credential as late as possible before calling curl to avoid logging feed_credential
  1033. # Avoid passing URI with credentials to functions: note, most of them echoing parameters of invocation in verbose output.
  1034. local remote_path_with_credential="${remote_path}${feed_credential}"
  1035. local curl_options="--retry 20 --retry-delay 2 --connect-timeout 15 -sSL -f --create-dirs "
  1036. local curl_exit_code=0;
  1037. if [ -z "$out_path" ]; then
  1038. curl_output=$(curl $curl_options "$remote_path_with_credential" 2>&1)
  1039. curl_exit_code=$?
  1040. echo "$curl_output"
  1041. else
  1042. curl_output=$(curl $curl_options -o "$out_path" "$remote_path_with_credential" 2>&1)
  1043. curl_exit_code=$?
  1044. fi
  1045. # Regression in curl causes curl with --retry to return a 0 exit code even when it fails to download a file - https://github.com/curl/curl/issues/17554
  1046. if [ $curl_exit_code -eq 0 ] && echo "$curl_output" | grep -q "^curl: ([0-9]*) "; then
  1047. curl_exit_code=$(echo "$curl_output" | sed 's/curl: (\([0-9]*\)).*/\1/')
  1048. fi
  1049. if [ $curl_exit_code -gt 0 ]; then
  1050. download_error_msg="Unable to download $remote_path."
  1051. # Check for curl timeout codes
  1052. if [[ $curl_exit_code == 7 || $curl_exit_code == 28 ]]; then
  1053. download_error_msg+=" Failed to reach the server: connection timeout."
  1054. else
  1055. local disable_feed_credential=false
  1056. local response=$(get_http_header_curl $remote_path $disable_feed_credential)
  1057. http_code=$( echo "$response" | awk '/^HTTP/{print $2}' | tail -1 )
  1058. if [[ ! -z $http_code && $http_code != 2* ]]; then
  1059. download_error_msg+=" Returned HTTP status code: $http_code."
  1060. fi
  1061. fi
  1062. say_verbose "$download_error_msg"
  1063. return 1
  1064. fi
  1065. return 0
  1066. }
  1067. # Updates global variables $http_code and $download_error_msg
  1068. downloadwget() {
  1069. eval $invocation
  1070. unset http_code
  1071. unset download_error_msg
  1072. local remote_path="$1"
  1073. local out_path="${2:-}"
  1074. # Append feed_credential as late as possible before calling wget to avoid logging feed_credential
  1075. local remote_path_with_credential="${remote_path}${feed_credential}"
  1076. local wget_options="--tries 20 "
  1077. local wget_options_extra=''
  1078. local wget_result=''
  1079. # Test for options that aren't supported on all wget implementations.
  1080. if [[ $(wget -h 2>&1 | grep -E 'waitretry|connect-timeout') ]]; then
  1081. wget_options_extra="--waitretry 2 --connect-timeout 15 "
  1082. else
  1083. say "wget extra options are unavailable for this environment"
  1084. fi
  1085. if [ -z "$out_path" ]; then
  1086. wget -q $wget_options $wget_options_extra -O - "$remote_path_with_credential" 2>&1
  1087. wget_result=$?
  1088. else
  1089. wget $wget_options $wget_options_extra -O "$out_path" "$remote_path_with_credential" 2>&1
  1090. wget_result=$?
  1091. fi
  1092. if [[ $wget_result != 0 ]]; then
  1093. local disable_feed_credential=false
  1094. local response=$(get_http_header_wget $remote_path $disable_feed_credential)
  1095. http_code=$( echo "$response" | awk '/^ HTTP/{print $2}' | tail -1 )
  1096. download_error_msg="Unable to download $remote_path."
  1097. if [[ ! -z $http_code && $http_code != 2* ]]; then
  1098. download_error_msg+=" Returned HTTP status code: $http_code."
  1099. # wget exit code 4 stands for network-issue
  1100. elif [[ $wget_result == 4 ]]; then
  1101. download_error_msg+=" Failed to reach the server: connection timeout."
  1102. fi
  1103. say_verbose "$download_error_msg"
  1104. return 1
  1105. fi
  1106. return 0
  1107. }
  1108. get_download_link_from_aka_ms() {
  1109. eval $invocation
  1110. #quality is not supported for LTS or STS channel
  1111. #STS maps to current
  1112. if [[ ! -z "$normalized_quality" && ("$normalized_channel" == "LTS" || "$normalized_channel" == "STS") ]]; then
  1113. normalized_quality=""
  1114. say_warning "Specifying quality for STS or LTS channel is not supported, the quality will be ignored."
  1115. fi
  1116. say_verbose "Retrieving primary payload URL from aka.ms for channel: '$normalized_channel', quality: '$normalized_quality', product: '$normalized_product', os: '$normalized_os', architecture: '$normalized_architecture'."
  1117. #construct aka.ms link
  1118. aka_ms_link="https://aka.ms/dotnet"
  1119. if [ "$internal" = true ]; then
  1120. aka_ms_link="$aka_ms_link/internal"
  1121. fi
  1122. aka_ms_link="$aka_ms_link/$normalized_channel"
  1123. if [[ ! -z "$normalized_quality" ]]; then
  1124. aka_ms_link="$aka_ms_link/$normalized_quality"
  1125. fi
  1126. aka_ms_link="$aka_ms_link/$normalized_product-$normalized_os-$normalized_architecture.tar.gz"
  1127. say_verbose "Constructed aka.ms link: '$aka_ms_link'."
  1128. #get HTTP response
  1129. #do not pass credentials as a part of the $aka_ms_link and do not apply credentials in the get_http_header function
  1130. #otherwise the redirect link would have credentials as well
  1131. #it would result in applying credentials twice to the resulting link and thus breaking it, and in echoing credentials to the output as a part of redirect link
  1132. disable_feed_credential=true
  1133. response="$(get_http_header $aka_ms_link $disable_feed_credential)"
  1134. say_verbose "Received response: $response"
  1135. # Get results of all the redirects.
  1136. http_codes=$( echo "$response" | awk '$1 ~ /^HTTP/ {print $2}' )
  1137. # Allow intermediate 301 redirects and tolerate proxy-injected 200s
  1138. broken_redirects=$( echo "$http_codes" | sed '$d' | grep -vE '^(301|200)$' )
  1139. # The response may end without final code 2xx/4xx/5xx somehow, e.g. network restrictions on www.bing.com causes redirecting to bing.com fails with connection refused.
  1140. # In this case it should not exclude the last.
  1141. last_http_code=$( echo "$http_codes" | tail -n 1 )
  1142. if ! [[ $last_http_code =~ ^(2|4|5)[0-9][0-9]$ ]]; then
  1143. broken_redirects=$( echo "$http_codes" | grep -vE '^(301|200)$' )
  1144. fi
  1145. # All HTTP codes are 301 (Moved Permanently), the redirect link exists.
  1146. if [[ -z "$broken_redirects" ]]; then
  1147. aka_ms_download_link=$( echo "$response" | awk '$1 ~ /^Location/{print $2}' | tail -1 | tr -d '\r')
  1148. if [[ -z "$aka_ms_download_link" ]]; then
  1149. say_verbose "The aka.ms link '$aka_ms_link' is not valid: failed to get redirect location."
  1150. return 1
  1151. fi
  1152. say_verbose "The redirect location retrieved: '$aka_ms_download_link'."
  1153. return 0
  1154. else
  1155. say_verbose "The aka.ms link '$aka_ms_link' is not valid: received HTTP code: $(echo "$broken_redirects" | paste -sd "," -)."
  1156. return 1
  1157. fi
  1158. }
  1159. get_feeds_to_use()
  1160. {
  1161. feeds=(
  1162. "https://builds.dotnet.microsoft.com/dotnet"
  1163. "https://ci.dot.net/public"
  1164. )
  1165. if [[ -n "$azure_feed" ]]; then
  1166. feeds=("$azure_feed")
  1167. fi
  1168. if [[ -n "$uncached_feed" ]]; then
  1169. feeds=("$uncached_feed")
  1170. fi
  1171. }
  1172. # THIS FUNCTION MAY EXIT (if the determined version is already installed).
  1173. generate_download_links() {
  1174. download_links=()
  1175. specific_versions=()
  1176. effective_versions=()
  1177. link_types=()
  1178. # If generate_akams_links returns false, no fallback to old links. Just terminate.
  1179. # This function may also 'exit' (if the determined version is already installed).
  1180. generate_akams_links || return
  1181. # Check other feeds only if we haven't been able to find an aka.ms link.
  1182. if [[ "${#download_links[@]}" -lt 1 ]]; then
  1183. for feed in ${feeds[@]}
  1184. do
  1185. # generate_regular_links may also 'exit' (if the determined version is already installed).
  1186. generate_regular_links $feed || return
  1187. done
  1188. fi
  1189. if [[ "${#download_links[@]}" -eq 0 ]]; then
  1190. say_err "Failed to resolve the exact version number."
  1191. return 1
  1192. fi
  1193. say_verbose "Generated ${#download_links[@]} links."
  1194. for link_index in ${!download_links[@]}
  1195. do
  1196. say_verbose "Link $link_index: ${link_types[$link_index]}, ${effective_versions[$link_index]}, ${download_links[$link_index]}"
  1197. done
  1198. }
  1199. # THIS FUNCTION MAY EXIT (if the determined version is already installed).
  1200. generate_akams_links() {
  1201. local valid_aka_ms_link=true;
  1202. normalized_version="$(to_lowercase "$version")"
  1203. if [[ "$normalized_version" != "latest" ]] && [ -n "$normalized_quality" ]; then
  1204. say_err "Quality and Version options are not allowed to be specified simultaneously. See https://learn.microsoft.com/dotnet/core/tools/dotnet-install-script#options for details."
  1205. return 1
  1206. fi
  1207. if [[ -n "$json_file" || "$normalized_version" != "latest" ]]; then
  1208. # aka.ms links are not needed when exact version is specified via command or json file
  1209. return
  1210. fi
  1211. get_download_link_from_aka_ms || valid_aka_ms_link=false
  1212. if [[ "$valid_aka_ms_link" == true ]]; then
  1213. say_verbose "Retrieved primary payload URL from aka.ms link: '$aka_ms_download_link'."
  1214. say_verbose "Downloading using legacy url will not be attempted."
  1215. download_link=$aka_ms_download_link
  1216. #get version from the path
  1217. IFS='/'
  1218. read -ra pathElems <<< "$download_link"
  1219. count=${#pathElems[@]}
  1220. specific_version="${pathElems[count-2]}"
  1221. unset IFS;
  1222. say_verbose "Version: '$specific_version'."
  1223. #Retrieve effective version
  1224. effective_version="$(get_specific_product_version "$azure_feed" "$specific_version" "$download_link")"
  1225. # Add link info to arrays
  1226. download_links+=($download_link)
  1227. specific_versions+=($specific_version)
  1228. effective_versions+=($effective_version)
  1229. link_types+=("aka.ms")
  1230. # Check if the SDK version is already installed.
  1231. if [[ "$dry_run" != true ]] && is_dotnet_package_installed "$install_root" "$asset_relative_path" "$effective_version"; then
  1232. say "$asset_name with version '$effective_version' is already installed."
  1233. exit 0
  1234. fi
  1235. return 0
  1236. fi
  1237. # if quality is specified - exit with error - there is no fallback approach
  1238. if [ ! -z "$normalized_quality" ]; then
  1239. say_err "Failed to locate the latest version in the channel '$normalized_channel' with '$normalized_quality' quality for '$normalized_product', os: '$normalized_os', architecture: '$normalized_architecture'."
  1240. say_err "Refer to: https://aka.ms/dotnet-os-lifecycle for information on .NET Core support."
  1241. return 1
  1242. fi
  1243. say_verbose "Falling back to latest.version file approach."
  1244. }
  1245. # THIS FUNCTION MAY EXIT (if the determined version is already installed)
  1246. # args:
  1247. # feed - $1
  1248. generate_regular_links() {
  1249. local feed="$1"
  1250. local valid_legacy_download_link=true
  1251. specific_version=$(get_specific_version_from_version "$feed" "$channel" "$normalized_architecture" "$version" "$json_file") || specific_version='0'
  1252. if [[ "$specific_version" == '0' ]]; then
  1253. say_verbose "Failed to resolve the specific version number using feed '$feed'"
  1254. return
  1255. fi
  1256. effective_version="$(get_specific_product_version "$feed" "$specific_version")"
  1257. say_verbose "specific_version=$specific_version"
  1258. download_link="$(construct_download_link "$feed" "$channel" "$normalized_architecture" "$specific_version" "$normalized_os")"
  1259. say_verbose "Constructed primary named payload URL: $download_link"
  1260. # Add link info to arrays
  1261. download_links+=($download_link)
  1262. specific_versions+=($specific_version)
  1263. effective_versions+=($effective_version)
  1264. link_types+=("primary")
  1265. legacy_download_link="$(construct_legacy_download_link "$feed" "$channel" "$normalized_architecture" "$specific_version")" || valid_legacy_download_link=false
  1266. if [ "$valid_legacy_download_link" = true ]; then
  1267. say_verbose "Constructed legacy named payload URL: $legacy_download_link"
  1268. download_links+=($legacy_download_link)
  1269. specific_versions+=($specific_version)
  1270. effective_versions+=($effective_version)
  1271. link_types+=("legacy")
  1272. else
  1273. legacy_download_link=""
  1274. say_verbose "Could not construct a legacy_download_link; omitting..."
  1275. fi
  1276. # Check if the SDK version is already installed.
  1277. if [[ "$dry_run" != true ]] && is_dotnet_package_installed "$install_root" "$asset_relative_path" "$effective_version"; then
  1278. say "$asset_name with version '$effective_version' is already installed."
  1279. exit 0
  1280. fi
  1281. }
  1282. print_dry_run() {
  1283. say "Payload URLs:"
  1284. for link_index in "${!download_links[@]}"
  1285. do
  1286. say "URL #$link_index - ${link_types[$link_index]}: ${download_links[$link_index]}"
  1287. done
  1288. resolved_version=${specific_versions[0]}
  1289. repeatable_command="./$script_name --version "\""$resolved_version"\"" --install-dir "\""$install_root"\"" --architecture "\""$normalized_architecture"\"" --os "\""$normalized_os"\"""
  1290. if [ ! -z "$normalized_quality" ]; then
  1291. repeatable_command+=" --quality "\""$normalized_quality"\"""
  1292. fi
  1293. if [[ "$runtime" == "dotnet" ]]; then
  1294. repeatable_command+=" --runtime "\""dotnet"\"""
  1295. elif [[ "$runtime" == "aspnetcore" ]]; then
  1296. repeatable_command+=" --runtime "\""aspnetcore"\"""
  1297. fi
  1298. repeatable_command+="$non_dynamic_parameters"
  1299. if [ -n "$feed_credential" ]; then
  1300. repeatable_command+=" --feed-credential "\""<feed_credential>"\"""
  1301. fi
  1302. say "Repeatable invocation: $repeatable_command"
  1303. }
  1304. calculate_vars() {
  1305. eval $invocation
  1306. script_name=$(basename "$0")
  1307. normalized_architecture="$(get_normalized_architecture_from_architecture "$architecture")"
  1308. say_verbose "Normalized architecture: '$normalized_architecture'."
  1309. normalized_os="$(get_normalized_os "$user_defined_os")"
  1310. say_verbose "Normalized OS: '$normalized_os'."
  1311. normalized_quality="$(get_normalized_quality "$quality")"
  1312. say_verbose "Normalized quality: '$normalized_quality'."
  1313. normalized_channel="$(get_normalized_channel "$channel")"
  1314. say_verbose "Normalized channel: '$normalized_channel'."
  1315. normalized_product="$(get_normalized_product "$runtime")"
  1316. say_verbose "Normalized product: '$normalized_product'."
  1317. install_root="$(resolve_installation_path "$install_dir")"
  1318. say_verbose "InstallRoot: '$install_root'."
  1319. normalized_architecture="$(get_normalized_architecture_for_specific_sdk_version "$version" "$normalized_channel" "$normalized_architecture")"
  1320. if [[ "$runtime" == "dotnet" ]]; then
  1321. asset_relative_path="shared/Microsoft.NETCore.App"
  1322. asset_name=".NET Core Runtime"
  1323. elif [[ "$runtime" == "aspnetcore" ]]; then
  1324. asset_relative_path="shared/Microsoft.AspNetCore.App"
  1325. asset_name="ASP.NET Core Runtime"
  1326. elif [ -z "$runtime" ]; then
  1327. asset_relative_path="sdk"
  1328. asset_name=".NET Core SDK"
  1329. fi
  1330. get_feeds_to_use
  1331. }
  1332. install_dotnet() {
  1333. eval $invocation
  1334. local download_failed=false
  1335. local download_completed=false
  1336. local remote_file_size=0
  1337. mkdir -p "$install_root"
  1338. zip_path="${zip_path:-$(mktemp "$temporary_file_template")}"
  1339. say_verbose "Archive path: $zip_path"
  1340. for link_index in "${!download_links[@]}"
  1341. do
  1342. download_link="${download_links[$link_index]}"
  1343. specific_version="${specific_versions[$link_index]}"
  1344. effective_version="${effective_versions[$link_index]}"
  1345. link_type="${link_types[$link_index]}"
  1346. say "Attempting to download using $link_type link $download_link"
  1347. # The download function will set variables $http_code and $download_error_msg in case of failure.
  1348. download_failed=false
  1349. download "$download_link" "$zip_path" 2>&1 || download_failed=true
  1350. if [ "$download_failed" = true ]; then
  1351. case ${http_code-} in
  1352. 404)
  1353. say "The resource at $link_type link '$download_link' is not available."
  1354. ;;
  1355. *)
  1356. say "Failed to download $link_type link '$download_link': ${http_code-} ${download_error_msg-}"
  1357. ;;
  1358. esac
  1359. rm -f "$zip_path" 2>&1 && say_verbose "Temporary archive file $zip_path was removed"
  1360. else
  1361. download_completed=true
  1362. break
  1363. fi
  1364. done
  1365. if [[ "$download_completed" == false ]]; then
  1366. say_err "Could not find \`$asset_name\` with version = $specific_version"
  1367. say_err "Refer to: https://aka.ms/dotnet-os-lifecycle for information on .NET Core support"
  1368. return 1
  1369. fi
  1370. remote_file_size="$(get_remote_file_size "$download_link")"
  1371. say "Extracting archive from $download_link"
  1372. extract_dotnet_package "$zip_path" "$install_root" "$remote_file_size" || return 1
  1373. # Check if the SDK version is installed; if not, fail the installation.
  1374. # if the version contains "RTM" or "servicing"; check if a 'release-type' SDK version is installed.
  1375. if [[ $specific_version == *"rtm"* || $specific_version == *"servicing"* ]]; then
  1376. IFS='-'
  1377. read -ra verArr <<< "$specific_version"
  1378. release_version="${verArr[0]}"
  1379. unset IFS;
  1380. say_verbose "Checking installation: version = $release_version"
  1381. if is_dotnet_package_installed "$install_root" "$asset_relative_path" "$release_version"; then
  1382. say "Installed version is $effective_version"
  1383. return 0
  1384. fi
  1385. fi
  1386. # Check if the standard SDK version is installed.
  1387. say_verbose "Checking installation: version = $effective_version"
  1388. if is_dotnet_package_installed "$install_root" "$asset_relative_path" "$effective_version"; then
  1389. say "Installed version is $effective_version"
  1390. return 0
  1391. fi
  1392. # Version verification failed. More likely something is wrong either with the downloaded content or with the verification algorithm.
  1393. say_err "Failed to verify the version of installed \`$asset_name\`.\nInstallation source: $download_link.\nInstallation location: $install_root.\nReport the bug at https://github.com/dotnet/install-scripts/issues."
  1394. say_err "\`$asset_name\` with version = $effective_version failed to install with an error."
  1395. return 1
  1396. }
  1397. args=("$@")
  1398. local_version_file_relative_path="/.version"
  1399. bin_folder_relative_path=""
  1400. temporary_file_template="${TMPDIR:-/tmp}/dotnet.XXXXXXXXX"
  1401. channel="LTS"
  1402. version="Latest"
  1403. json_file=""
  1404. install_dir="<auto>"
  1405. architecture="<auto>"
  1406. dry_run=false
  1407. no_path=false
  1408. azure_feed=""
  1409. uncached_feed=""
  1410. feed_credential=""
  1411. verbose=false
  1412. runtime=""
  1413. runtime_id=""
  1414. quality=""
  1415. internal=false
  1416. override_non_versioned_files=true
  1417. non_dynamic_parameters=""
  1418. user_defined_os=""
  1419. while [ $# -ne 0 ]
  1420. do
  1421. name="$1"
  1422. case "$name" in
  1423. -c|--channel|-[Cc]hannel)
  1424. shift
  1425. channel="$1"
  1426. ;;
  1427. -v|--version|-[Vv]ersion)
  1428. shift
  1429. version="$1"
  1430. ;;
  1431. -q|--quality|-[Qq]uality)
  1432. shift
  1433. quality="$1"
  1434. ;;
  1435. --internal|-[Ii]nternal)
  1436. internal=true
  1437. non_dynamic_parameters+=" $name"
  1438. ;;
  1439. -i|--install-dir|-[Ii]nstall[Dd]ir)
  1440. shift
  1441. install_dir="$1"
  1442. ;;
  1443. --arch|--architecture|-[Aa]rch|-[Aa]rchitecture)
  1444. shift
  1445. architecture="$1"
  1446. ;;
  1447. --os|-[Oo][SS])
  1448. shift
  1449. user_defined_os="$1"
  1450. ;;
  1451. --shared-runtime|-[Ss]hared[Rr]untime)
  1452. say_warning "The --shared-runtime flag is obsolete and may be removed in a future version of this script. The recommended usage is to specify '--runtime dotnet'."
  1453. if [ -z "$runtime" ]; then
  1454. runtime="dotnet"
  1455. fi
  1456. ;;
  1457. --runtime|-[Rr]untime)
  1458. shift
  1459. runtime="$1"
  1460. if [[ "$runtime" != "dotnet" ]] && [[ "$runtime" != "aspnetcore" ]]; then
  1461. say_err "Unsupported value for --runtime: '$1'. Valid values are 'dotnet' and 'aspnetcore'."
  1462. if [[ "$runtime" == "windowsdesktop" ]]; then
  1463. say_err "WindowsDesktop archives are manufactured for Windows platforms only."
  1464. fi
  1465. exit 1
  1466. fi
  1467. ;;
  1468. --dry-run|-[Dd]ry[Rr]un)
  1469. dry_run=true
  1470. ;;
  1471. --no-path|-[Nn]o[Pp]ath)
  1472. no_path=true
  1473. non_dynamic_parameters+=" $name"
  1474. ;;
  1475. --verbose|-[Vv]erbose)
  1476. verbose=true
  1477. non_dynamic_parameters+=" $name"
  1478. ;;
  1479. --azure-feed|-[Aa]zure[Ff]eed)
  1480. shift
  1481. azure_feed="$1"
  1482. non_dynamic_parameters+=" $name "\""$1"\"""
  1483. ;;
  1484. --uncached-feed|-[Uu]ncached[Ff]eed)
  1485. shift
  1486. uncached_feed="$1"
  1487. non_dynamic_parameters+=" $name "\""$1"\"""
  1488. ;;
  1489. --feed-credential|-[Ff]eed[Cc]redential)
  1490. shift
  1491. feed_credential="$1"
  1492. #feed_credential should start with "?", for it to be added to the end of the link.
  1493. #adding "?" at the beginning of the feed_credential if needed.
  1494. [[ -z "$(echo $feed_credential)" ]] || [[ $feed_credential == \?* ]] || feed_credential="?$feed_credential"
  1495. ;;
  1496. --runtime-id|-[Rr]untime[Ii]d)
  1497. shift
  1498. runtime_id="$1"
  1499. non_dynamic_parameters+=" $name "\""$1"\"""
  1500. say_warning "Use of --runtime-id is obsolete and should be limited to the versions below 2.1. To override architecture, use --architecture option instead. To override OS, use --os option instead."
  1501. ;;
  1502. --jsonfile|-[Jj][Ss]on[Ff]ile)
  1503. shift
  1504. json_file="$1"
  1505. ;;
  1506. --skip-non-versioned-files|-[Ss]kip[Nn]on[Vv]ersioned[Ff]iles)
  1507. override_non_versioned_files=false
  1508. non_dynamic_parameters+=" $name"
  1509. ;;
  1510. --keep-zip|-[Kk]eep[Zz]ip)
  1511. keep_zip=true
  1512. non_dynamic_parameters+=" $name"
  1513. ;;
  1514. --zip-path|-[Zz]ip[Pp]ath)
  1515. shift
  1516. zip_path="$1"
  1517. ;;
  1518. -?|--?|-h|--help|-[Hh]elp)
  1519. script_name="dotnet-install.sh"
  1520. echo ".NET Tools Installer"
  1521. echo "Usage:"
  1522. echo " # Install a .NET SDK of a given Quality from a given Channel"
  1523. echo " $script_name [-c|--channel <CHANNEL>] [-q|--quality <QUALITY>]"
  1524. echo " # Install a .NET SDK of a specific public version"
  1525. echo " $script_name [-v|--version <VERSION>]"
  1526. echo " $script_name -h|-?|--help"
  1527. echo ""
  1528. echo "$script_name is a simple command line interface for obtaining dotnet cli."
  1529. echo " Note that the intended use of this script is for Continuous Integration (CI) scenarios, where:"
  1530. echo " - The SDK needs to be installed without user interaction and without admin rights."
  1531. echo " - The SDK installation doesn't need to persist across multiple CI runs."
  1532. echo " To set up a development environment or to run apps, use installers rather than this script. Visit https://dotnet.microsoft.com/download to get the installer."
  1533. echo ""
  1534. echo "Options:"
  1535. echo " -c,--channel <CHANNEL> Download from the channel specified, Defaults to \`$channel\`."
  1536. echo " -Channel"
  1537. echo " Possible values:"
  1538. echo " - STS - the most recent Standard Term Support release"
  1539. echo " - LTS - the most recent Long Term Support release"
  1540. echo " - 2-part version in a format A.B - represents a specific release"
  1541. echo " examples: 2.0; 1.0"
  1542. echo " - 3-part version in a format A.B.Cxx - represents a specific SDK release"
  1543. echo " examples: 5.0.1xx, 5.0.2xx."
  1544. echo " Supported since 5.0 release"
  1545. echo " Warning: Value 'Current' is deprecated for the Channel parameter. Use 'STS' instead."
  1546. echo " Note: The version parameter overrides the channel parameter when any version other than 'latest' is used."
  1547. echo " -v,--version <VERSION> Use specific VERSION, Defaults to \`$version\`."
  1548. echo " -Version"
  1549. echo " Possible values:"
  1550. echo " - latest - the latest build on specific channel"
  1551. echo " - 3-part version in a format A.B.C - represents specific version of build"
  1552. echo " examples: 2.0.0-preview2-006120; 1.1.0"
  1553. echo " -q,--quality <quality> Download the latest build of specified quality in the channel."
  1554. echo " -Quality"
  1555. echo " The possible values are: daily, preview, GA."
  1556. echo " Works only in combination with channel. Not applicable for STS and LTS channels and will be ignored if those channels are used."
  1557. echo " Supported since 5.0 release."
  1558. echo " Note: The version parameter overrides the channel parameter when any version other than 'latest' is used, and therefore overrides the quality."
  1559. echo " --internal,-Internal Download internal builds. Requires providing credentials via --feed-credential parameter."
  1560. echo " --feed-credential <FEEDCREDENTIAL> Token to access Azure feed. Used as a query string to append to the Azure feed."
  1561. echo " -FeedCredential This parameter typically is not specified."
  1562. echo " -i,--install-dir <DIR> Install under specified location (see Install Location below)"
  1563. echo " -InstallDir"
  1564. echo " --architecture <ARCHITECTURE> Architecture of dotnet binaries to be installed, Defaults to \`$architecture\`."
  1565. echo " --arch,-Architecture,-Arch"
  1566. echo " Possible values: x64, arm, arm64, s390x, ppc64le and loongarch64"
  1567. echo " --os <system> Specifies operating system to be used when selecting the installer."
  1568. echo " Overrides the OS determination approach used by the script. Supported values: osx, linux, linux-musl, freebsd, rhel.6."
  1569. echo " In case any other value is provided, the platform will be determined by the script based on machine configuration."
  1570. echo " Not supported for legacy links. Use --runtime-id to specify platform for legacy links."
  1571. echo " Refer to: https://aka.ms/dotnet-os-lifecycle for more information."
  1572. echo " --runtime <RUNTIME> Installs a shared runtime only, without the SDK."
  1573. echo " -Runtime"
  1574. echo " Possible values:"
  1575. echo " - dotnet - the Microsoft.NETCore.App shared runtime"
  1576. echo " - aspnetcore - the Microsoft.AspNetCore.App shared runtime"
  1577. echo " --dry-run,-DryRun Do not perform installation. Display download link."
  1578. echo " --no-path, -NoPath Do not set PATH for the current process."
  1579. echo " --verbose,-Verbose Display diagnostics information."
  1580. echo " --azure-feed,-AzureFeed For internal use only."
  1581. echo " Allows using a different storage to download SDK archives from."
  1582. echo " --uncached-feed,-UncachedFeed For internal use only."
  1583. echo " Allows using a different storage to download SDK archives from."
  1584. echo " --skip-non-versioned-files Skips non-versioned files if they already exist, such as the dotnet executable."
  1585. echo " -SkipNonVersionedFiles"
  1586. echo " --jsonfile <JSONFILE> Determines the SDK version from a user specified global.json file."
  1587. echo " Note: global.json must have a value for 'SDK:Version'"
  1588. echo " --keep-zip,-KeepZip If set, downloaded file is kept."
  1589. echo " --zip-path, -ZipPath If set, downloaded file is stored at the specified path."
  1590. echo " -?,--?,-h,--help,-Help Shows this help message"
  1591. echo ""
  1592. echo "Install Location:"
  1593. echo " Location is chosen in following order:"
  1594. echo " - --install-dir option"
  1595. echo " - Environmental variable DOTNET_INSTALL_DIR"
  1596. echo " - $HOME/.dotnet"
  1597. exit 0
  1598. ;;
  1599. *)
  1600. say_err "Unknown argument \`$name\`"
  1601. exit 1
  1602. ;;
  1603. esac
  1604. shift
  1605. done
  1606. say_verbose "Note that the intended use of this script is for Continuous Integration (CI) scenarios, where:"
  1607. say_verbose "- The SDK needs to be installed without user interaction and without admin rights."
  1608. say_verbose "- The SDK installation doesn't need to persist across multiple CI runs."
  1609. say_verbose "To set up a development environment or to run apps, use installers rather than this script. Visit https://dotnet.microsoft.com/download to get the installer.\n"
  1610. if [ "$internal" = true ] && [ -z "$(echo $feed_credential)" ]; then
  1611. message="Provide credentials via --feed-credential parameter."
  1612. if [ "$dry_run" = true ]; then
  1613. say_warning "$message"
  1614. else
  1615. say_err "$message"
  1616. exit 1
  1617. fi
  1618. fi
  1619. check_min_reqs
  1620. calculate_vars
  1621. # generate_regular_links call below will 'exit' if the determined version is already installed.
  1622. generate_download_links
  1623. if [[ "$dry_run" = true ]]; then
  1624. print_dry_run
  1625. exit 0
  1626. fi
  1627. install_dotnet
  1628. bin_path="$(get_absolute_path "$(combine_paths "$install_root" "$bin_folder_relative_path")")"
  1629. if [ "$no_path" = false ]; then
  1630. say "Adding to current process PATH: \`$bin_path\`. Note: This change will be visible only when sourcing script."
  1631. export PATH="$bin_path":"$PATH"
  1632. else
  1633. say "Binaries of dotnet can be found in $bin_path"
  1634. fi
  1635. say "Note that the script does not resolve dependencies during installation."
  1636. say "To check the list of dependencies, go to https://learn.microsoft.com/dotnet/core/install, select your operating system and check the \"Dependencies\" section."
  1637. say "Installation finished successfully."