記錄一下自己在開發過程遇到的問題
在網上找了好久關於蘋果系統卸載Net Core資料很難找到,在此寫一下筆記
因為第一次就安裝了Net Core 3.0版本的
現在打開的項目版本的Net Core 2.2.0 版本
因此不兼容,要把他卸載
這里我自己把代碼粘進來
1 DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" 2 3 # 判斷有沒有sudo權限 4 current_userid=$(id -u) 5 if [ $current_userid -ne 0 ]; then 6 echo "$(basename "$0") uninstallation script requires superuser privileges to run" >&2 7 exit 1 8 fi 9 10 # this is the common suffix for all the dotnet pkgs 11 # .NET Core pkg文件的安裝前綴 12 dotnet_pkg_name_suffix="com.microsoft.dotnet" 13 # 安裝目錄與配置文件 14 dotnet_install_root="/usr/local/share/dotnet" 15 dotnet_path_file="/etc/paths.d/dotnet" 16 dotnet_tool_path_file="/etc/paths.d/dotnet-cli-tools" 17 18 remove_dotnet_pkgs(){ 19 # 使用pkgutil工具查詢已安裝的.NET Core pkg(通過com.microsoft.dotnet查詢) 20 installed_pkgs=($(pkgutil --pkgs | grep $dotnet_pkg_name_suffix)) 21 22 for i in "${installed_pkgs[@]}" 23 do 24 echo "Removing dotnet component - \"$i\"" >&2 25 #使用 pkgutil 刪除.NET Core 組件 26 pkgutil --force --forget "$i" 27 done 28 } 29 #調用刪除函數 30 remove_dotnet_pkgs 31 [ "$?" -ne 0 ] && echo "Failed to remove dotnet packages." >&2 && exit 1 32 33 echo "Deleting install root - $dotnet_install_root" >&2 34 # 刪除文件夾及配置 35 rm -rf "$dotnet_install_root" 36 rm -f "$dotnet_path_file" 37 rm -f "$dotnet_tool_path_file" 38 39 echo "dotnet packages removal succeeded." >&2 40 exit 0
用記事本或者Visual studio Code 保存格式為 ~.sh
打開MAC 自帶控制台 切換的剛剛保存好的路徑
執行命令 sudo sh ./~.sh
執行完成,輸入DotNet --version 或者 DotNet --info
查看是否還在,如果沒有就成功了,這里留下一個開發者的交流群,希望能幫到大家