关于.Net Core平台在苹果Mac系统快速卸载

记录一下自己在开发过程遇到的问题

在网上找了好久关于苹果系统卸载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 

查看是否还在,如果没有就成功了,这里留下一个开发者的交流群,希望能帮到大家

猜你喜欢

转载自www.cnblogs.com/Aice/p/11601222.html