Hey, Tea Lovers! Lets see how to install single or multiple .NET SDKs on macOS and switch between them.

Option 1: Using Homebrew

The latest one can be directly installed by following command.

brew install --cask dotnet-sdk

For a specific version just suffix it with @<version> Example, for .NET 8 it would be,

brew install --cask dotnet-sdk@8

Simply paste in terminal and run.

Note: Homebrew currently only has limited versions so older versions might not be available. In that case, use Option 2 or 3.

Option 2: Manual Download and Install

  • Go to .NET downloads Page
  • Click on any desired version, I will be selecting .NET 8
  • In the SDK’s table, download for your platform, select from the installer column.
    • Arm64 - for M-Chips MacBooks.
  • After download, simply double click to install the downloaded .pkg file.

Option 3: Install via dotnet-install Script

This one I am using personally using on my windows machine. This is an official script from microsoft.

1. Download the Script

curl -fsSL https://dot.net/v1/dotnet-install.sh -o dotnet-install.sh
chmod +x dotnet-install.sh

2. Install a Specific Version

Install the latest LTS release (if want a LTS version, else skip)

./dotnet-install.sh --channel LTS

Install a specific version:

./dotnet-install.sh --version 8.0.419

By default, the SDK is installed to ~/.dotnet/.

3. Add to PATH

Since this method doesn’t modify your system PATH automatically, add the following to your shell profile (~/.zshrc for Zsh)

export DOTNET_ROOT="$HOME/.dotnet"
export PATH="$PATH:$HOME/.dotnet:$HOME/.dotnet/tools"

Then reload your shell:

source ~/.zshrc

Validate Installation

Run the following command:

dotnet --version

Should return the installed version.

Install Different dotnet SDK versions

Repeat the same process as mentioned above to install another version of the SDKs.

After installation of multiple .NET SDKs, run the following commands to see all the installed versions.

dotnet --list-sdk

It should return the list of sdks. For example, for me its showing this:

8.0.419 [/usr/local/share/dotnet/sdk]
10.0.201 [/usr/local/share/dotnet/sdk]

Select a specific version

In project, you can specify which version to use. Read more about it here.

lets see how you can make the dotnet command on machine to use specific version.

  1. Run the dotnet --list-sdk command to get all the version.
  2. Copy the version you want to use. Example. 8.0.419
  3. In the home directory ~/ , create the global.json file.
    1. You can manually create the file or use the command dotnet new globaljson
    2. Change the SDK version.
  4. global.json should look like following where version value is your desired version.
{
  "sdk": {
    "version": "8.0.419"
  }
}

Check the version again via dotnet --version command, should be the one specified in the global.json.


Thats it. See you in the next post!!!