@@ -638,7 +638,7 @@ get_version_from_latestversion_file() {
638
638
639
639
# args:
640
640
# json_file - $1
641
- parse_globaljson_file_for_version () {
641
+ parse_globaljson_file () {
642
642
eval $invocation
643
643
644
644
local json_file=" $1 "
@@ -657,55 +657,100 @@ parse_globaljson_file_for_version() {
657
657
sdk_list=${sdk_list// [\" ]/ }
658
658
sdk_list=${sdk_list// ,/ $' \n ' }
659
659
660
- local version_info=" "
661
660
while read -r line; do
662
661
IFS=:
663
662
while read -r key value; do
664
663
if [[ " $key " == " version" ]]; then
665
- version_info=$value
664
+ globaljson_version=$value
665
+ elif [[ " $key " == " rollForward" ]]; then
666
+ globaljson_roll_forward=$value
666
667
fi
667
668
done <<< " $line"
668
669
done <<< " $sdk_list"
669
- if [ -z " $version_info " ]; then
670
- say_err " Unable to find the SDK:version node in \` $json_file \` "
671
- return 1
672
- fi
673
670
674
671
unset IFS;
675
- echo " $version_info "
676
672
return 0
677
673
}
678
674
675
+ process_globaljson_file () {
676
+ if [[ -n " $json_file " ]]; then
677
+ globaljson_version=" "
678
+ globaljson_roll_forward=" "
679
+ parse_globaljson_file " $json_file " || return 1
680
+
681
+ # https://learn.microsoft.com/en-us/dotnet/core/tools/global-json#matching-rules
682
+ if [[ -z " $globaljson_roll_forward " ]]; then
683
+ if [[ -z " $globaljson_version " ]]; then
684
+ globaljson_roll_forward=" latestMajor"
685
+ else
686
+ globaljson_roll_forward=" latestPatch"
687
+ fi
688
+ fi
689
+
690
+ if [[ -n " $globaljson_version " ]]; then
691
+ IFS=' .'
692
+ read -ra parts <<< " $globaljson_version"
693
+ unset IFS
694
+
695
+ local major=" ${parts[0]} "
696
+ local minor=" ${parts[1]} "
697
+ local featureBand=" ${parts[2]: 0: 1} "
698
+ fi
699
+
700
+ case " $globaljson_roll_forward " in
701
+ disable|major|minor|feature|patch)
702
+ version=" $globaljson_version " ;
703
+ ;;
704
+
705
+ latestMajor)
706
+ version=" latest"
707
+ channel=" STS" # TODO this doesn't do what it should https://github.com/dotnet/install-scripts/issues/418
708
+ ;;
709
+
710
+ latestMinor)
711
+ version=" latest"
712
+ channel=" ${major} .x" # TODO this doesn't work
713
+ ;;
714
+
715
+ latestFeature)
716
+ version=" latest"
717
+ channel=" ${major} .${minor} "
718
+ ;;
719
+
720
+ latestPatch)
721
+ version=" latest"
722
+ channel=" ${major} .${minor} .${featureBand} xx"
723
+ ;;
724
+
725
+ * )
726
+ say_err " Unsupported rollForward option: $globaljson_roll_forward "
727
+ return 1
728
+ ;;
729
+ esac
730
+ fi
731
+ }
732
+
679
733
# args:
680
734
# azure_feed - $1
681
735
# channel - $2
682
736
# normalized_architecture - $3
683
737
# version - $4
684
- # json_file - $5
685
738
get_specific_version_from_version () {
686
739
eval $invocation
687
740
688
741
local azure_feed=" $1 "
689
742
local channel=" $2 "
690
743
local normalized_architecture=" $3 "
691
744
local version=" $( to_lowercase " $4 " ) "
692
- local json_file=" $5 "
693
-
694
- if [ -z " $json_file " ]; then
695
- if [[ " $version " == " latest" ]]; then
696
- local version_info
697
- version_info=" $( get_version_from_latestversion_file " $azure_feed " " $channel " " $normalized_architecture " false) " || return 1
698
- say_verbose " get_specific_version_from_version: version_info=$version_info "
699
- echo " $version_info " | get_version_from_latestversion_file_content
700
- return 0
701
- else
702
- echo " $version "
703
- return 0
704
- fi
705
- else
745
+
746
+ if [[ " $version " == " latest" ]]; then
706
747
local version_info
707
- version_info=" $( parse_globaljson_file_for_version " $json_file " ) " || return 1
708
- echo " $version_info "
748
+ version_info=" $( get_version_from_latestversion_file " $azure_feed " " $channel " " $normalized_architecture " false) " || return 1
749
+ say_verbose " get_specific_version_from_version: version_info=$version_info "
750
+ echo " $version_info " | get_version_from_latestversion_file_content
751
+ return 0
752
+ else
753
+ echo " $version "
709
754
return 0
710
755
fi
711
756
}
@@ -1361,8 +1406,8 @@ generate_akams_links() {
1361
1406
return 1
1362
1407
fi
1363
1408
1364
- if [[ -n " $json_file " || " $normalized_version " != " latest" ]]; then
1365
- # aka.ms links are not needed when exact version is specified via command or json file
1409
+ if [[ " $normalized_version " != " latest" ]]; then
1410
+ # aka.ms links are not needed when exact version is specified via command
1366
1411
return
1367
1412
fi
1368
1413
@@ -1416,7 +1461,7 @@ generate_regular_links() {
1416
1461
local feed=" $1 "
1417
1462
local valid_legacy_download_link=true
1418
1463
1419
- specific_version=$( get_specific_version_from_version " $feed " " $channel " " $normalized_architecture " " $version " " $json_file " ) || specific_version=' 0'
1464
+ specific_version=$( get_specific_version_from_version " $feed " " $channel " " $normalized_architecture " " $version " ) || specific_version=' 0'
1420
1465
1421
1466
if [[ " $specific_version " == ' 0' ]]; then
1422
1467
say_verbose " Failed to resolve the specific version number using feed '$feed '"
@@ -1503,6 +1548,7 @@ calculate_vars() {
1503
1548
say_verbose " Normalized product: '$normalized_product '."
1504
1549
install_root=" $( resolve_installation_path " $install_dir " ) "
1505
1550
say_verbose " InstallRoot: '$install_root '."
1551
+ say_verbose " Version: '$version '."
1506
1552
1507
1553
normalized_architecture=" $( get_normalized_architecture_for_specific_sdk_version " $version " " $normalized_channel " " $normalized_architecture " ) "
1508
1554
1799
1845
echo " -SkipNonVersionedFiles"
1800
1846
echo " --no-cdn,-NoCdn Disable downloading from the Azure CDN, and use the uncached feed directly."
1801
1847
echo " --jsonfile <JSONFILE> Determines the SDK version from a user specified global.json file."
1802
- echo " Note: global.json must have a value for 'SDK:Version'"
1803
1848
echo " --keep-zip,-KeepZip If set, downloaded file is kept."
1804
1849
echo " --zip-path, -ZipPath If set, downloaded file is stored at the specified path."
1805
1850
echo " -?,--?,-h,--help,-Help Shows this help message"
@@ -1836,6 +1881,7 @@ if [ "$internal" = true ] && [ -z "$(echo $feed_credential)" ]; then
1836
1881
fi
1837
1882
1838
1883
check_min_reqs
1884
+ process_globaljson_file
1839
1885
calculate_vars
1840
1886
# generate_regular_links call below will 'exit' if the determined version is already installed.
1841
1887
generate_download_links
0 commit comments