40

I have tried to install dotnet core, but it does not worked. So, I would like to uninstall it and start refresh. How can I uninstall dotnet core from macOS Sierra(10.12.3).

you can find below, existing dotnet core info on the system

/usr/local/share/dotnet/sdk$ ls -la
total 0
drwxr-xr-x    4 root  wheel   136 May 20 18:28 .
drwxr-xr-x   10 root  wheel   340 May 20 20:44 ..
drwxr-xr-x  142 root  wheel  4828 May 20 20:44 1.0.4
drwxr-xr-x  121 root  wheel  4114 May  9 23:04 2.0.0-preview1-005977


/usr/local/share/dotnet/sdk$ sudo find / -name dotnet
find: /dev/fd/sdk: No such file or directory
find: /dev/fd/sdk: No such file or directory
/private/etc/paths.d/dotnet
/Users/melihtt/.dotnet/NuGetFallbackFolder/microsoft.codeanalysis.analyzers/1.1.0/analyzers/dotnet
/Users/melihtt/.dotnet/optimizationdata/2.0.0-preview1-005977/osx.10.12-x64/dotnet
/usr/local/share/dotnet
/usr/local/share/dotnet/dotnet
/usr/local/share/dotnet/shared/Microsoft.NETCore.App/1.0.5/dotnet
/usr/local/share/dotnet/shared/Microsoft.NETCore.App/1.1.2/dotnet
Sanket
  • 19,295
  • 10
  • 71
  • 82
clockworks
  • 3,755
  • 5
  • 37
  • 46

4 Answers4

121

To uninstall dotnet core from macOS:

  1. download dotnet-uninstall-pkgs.sh from https://github.com/dotnet/sdk/blob/main/scripts/obtain/uninstall/dotnet-uninstall-pkgs.sh
  2. make dotnet-uninstall-pkgs.sh executable
  3. execute dotnet-uninstall-pkgs.sh as root (requires superuser privileges to run).
curl -O https://raw.githubusercontent.com/dotnet/sdk/main/scripts/obtain/uninstall/dotnet-uninstall-pkgs.sh
chmod u+x dotnet-uninstall-pkgs.sh
sudo ./dotnet-uninstall-pkgs.sh
John Korsnes
  • 2,277
  • 2
  • 20
  • 31
kimbaudi
  • 13,655
  • 9
  • 62
  • 74
  • 1
    Thanks for this. The official uninstaller binary would not help me with this, but link you provided cleaned up my system. – amiroff Mar 11 '20 at 04:49
4

If you are using the M1 Mac

  1. Confirm your cpu architecture

    ls /usr/local/share/dotnet/

  2. This may be x64 or x86. Set a variable to store the cpu arch

    arch="x64"

  3. Confirm your dotnet version

    dotnet --version

  4. Set a variable to store the version

    version="5.0.403"

  5. Run the following commands

    sudo rm -rf /usr/local/share/dotnet/$arch/sdk/$version

    sudo rm -rf /usr/local/share/dotnet/$arch/shared/Microsoft.NETCore.App/$version

    sudo rm -rf /usr/local/share/dotnet/$arch/shared/Microsoft.AspNetCore.All/$version

    sudo rm -rf /usr/local/share/dotnet/$arch/shared/Microsoft.AspNetCore.App/$version

    sudo rm -rf /usr/local/share/dotnet/$arch/host/fxr/$version

  6. Some of the above folders may not exist but that is fine. Confirm that no dotnet sdk is still present

    ls /usr/local/share/dotnet/$arch/sdk/ dotnet --version

Kyamasam
  • 183
  • 2
  • 5
4

To uninstall dotnet core from MacOS, using dotnet-uninstall-tool.

  1. Download the tool Here

  2. Open terminal and change working directory to where the file (dotnet-core-uninstall.tar.gz) is located.

  3. Install the Tool using following commands.

       1. mkdir -p ~/dotnet-core-uninstall
       2. tar -zxf dotnet-core-uninstall.tar.gz -C ~/dotnet-core-uninstall
       3. cd ~/dotnet-core-uninstall
    

show help: ./dotnet-core-uninstall -h

  1. ./dotnet-core-uninstall list

Using this command you can check the list of .NET Core SDKS or Runtime that can be removed with this tool.

  1. ./dotnet-core-uninstall remove --sdk/--runtime version --force

Eg: For remove SDK 5.0.100

./dotnet-core-uninstall remove --sdk 5.0.100 --force

If you face any Privilege issue add sudo in front of the command

  1. Give the user Key (Password).

  2. (Do you want to continue) hit the "Y" then enter.

Check & conform the SDK list

0

You might as well use dotnet-core-uninstall tool which allow you to select a specific SDK or runtime version to remove. github docs

If you are experiencing issues with building Xamarin.Mac after installing preview version of .Net 5 SDK you might like to remove Mono using such script and Visual Studio like this and try to reinstall from scratch

good luck