Skip to content

Commit 50f0234

Browse files
select-xamarin-sdk-v2 (actions#3290)
* select-xamarin-sdk-v2 * Update select-xamarin-sdk-v2.sh * change warning message * check existed framework version * check framework version review points
1 parent 365e5a0 commit 50f0234

1 file changed

Lines changed: 46 additions & 0 deletions

File tree

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
#!/bin/bash -e -o pipefail
2+
get_framework_path() {
3+
case $1 in
4+
--mono) echo '/Library/Frameworks/Mono.framework/Versions' ;;
5+
--ios) echo '/Library/Frameworks/Xamarin.iOS.framework/Versions' ;;
6+
--android) echo '/Library/Frameworks/Xamarin.Android.framework/Versions' ;;
7+
--mac) echo '/Library/Frameworks/Xamarin.Mac.framework/Versions' ;;
8+
*) ;;
9+
esac
10+
}
11+
12+
change_framework_version() {
13+
local framework=$1
14+
local version=$2
15+
16+
echo "Select $framework $version"
17+
18+
local countDigit=$(echo "${version}" | grep -o "\." | grep -c "\.")
19+
20+
if [[ countDigit -gt 1 ]]; then
21+
echo "[WARNING] It is not recommended to specify the exact framework version because your build can be broken with the next patch update. Consider using "major.minor" only format."
22+
fi
23+
24+
local framework_path=$(get_framework_path "$framework")
25+
26+
if [ -d "${framework_path}/${version}" ]; then
27+
sudo rm -f "${framework_path}/Current"
28+
sudo ln -s "${framework_path}/${version}" "${framework_path}/Current"
29+
else
30+
echo "Invalid framework version ${framework_path}/${version}"
31+
exit 1
32+
fi
33+
}
34+
35+
for arg in "$@"; do
36+
key=$(echo $arg | cut -f1 -d=)
37+
value=$(echo $arg | cut -f2 -d=)
38+
39+
case $key in
40+
--mono | --ios | --android | --mac) change_framework_version $key $value ;;
41+
*)
42+
echo "Invalid parameter <${key}>"
43+
exit 1
44+
;;
45+
esac
46+
done

0 commit comments

Comments
 (0)