Installing Multiple .NET Versions on macOS with Homebrew

A simple guide on how to install multiple .NET SDK versions side by side on macOS using the Homebrew package manager.

If you’re a .NET developer using macOS, you may want to install multiple .NET SDK versions side by side. While you can do this manually, it can become a headache to maintain in the long term. As you install more SDKs, leftover files can accumulate and fill up your storage.

Uninstalling older versions manually can also be tedious. You can refer to the official documentation for removal instructions. I even wrote an uninstallation guide to remind myself how to do it properly.

A more elegant solution is to use the Homebrew package manager to manage .NET SDK installations on macOS. But the official Homebrew cask for .NET does not allow multiple SDK versions to be installed at the same time. When you install one version, it prevents you from using others.

This can be problematic if you need to work on projects that require different .NET versions. While upgrading projects to the latest .NET version is often ideal, sometimes it’s not feasible.

To address this issue, I created a dedicated Homebrew tap for .NET.

Using it is simple. Here’s how.

Quickstart

Before using this Homebrew .NET tap, first uninstall any existing dotnet-sdk formula from the core Homebrew cask if you have it installed:

brew uninstall --zap dotnet-sdk

Once that’s done, tap my repository:

brew tap junian/homebrew-dotnet

For example, to install the .NET 10 SDK:

brew install dotnet-sdk@10.0

That’s it! Now you can use .NET 10 on your macOS system.

.NET SDK Versions

⭐️ Supported versions

Where is .NET 4 / .NET Core 4?

There is no .NET 4 or .NET Core 4. Version 4.x is reserved for .NET Framework, which only runs on Windows.

Microsoft transitioned from .NET Core to simply .NET starting with version 5.

The closest alternative to .NET Framework 4.x on macOS is Mono MDK.

.NET Core SDK Versions

Special Note for .NET Core 3.1 and .NET 5

On Apple Silicon Macs, if you install .NET Core 3.1 or .NET 5, the dotnet binary is located at:

/usr/local/share/dotnet/x64/dotnet

You can create an alias:

alias dotnet-x64=/usr/local/share/dotnet/x64/dotnet

Then use it, for example:

% dotnet-x64 --list-sdks
3.1.426 [/usr/local/share/dotnet/x64/sdk]
5.0.408 [/usr/local/share/dotnet/x64/sdk]

Mono MDK Version

Before Microsoft created a cross-platform .NET, there was a community-developed .NET-compatible implementation called Mono.

Xamarin Versions

These packages depend on Mono MDK:

Visual Studio for Mac

This application also depends on Mono MDK:

Side-by-side Installation Scenario

Let’s consider a scenario. You’re now using .NET 10 for new projects, so you have it installed with Homebrew.

brew install dotnet-sdk@10.0

Suppose a client needs a bug fix for a project that still uses .NET 6.0. You can install it with:

brew install dotnet-sdk@6.0

Now you can use .NET 6.0 to work on that project.

Later, if the client wants to migrate to .NET 9, you can install it as well:

brew install dotnet-sdk@9.0

When you no longer need .NET 6.0, simply remove it:

brew uninstall dotnet-sdk@6.0

You’ll still have .NET 9 and .NET 10 installed on your macOS. It’s that easy!

Conclusion

That’s all for today. I hope this simple guide helps you manage .NET SDKs on your macOS.

For more details, check out the documentation for the Homebrew .NET tap.

If you have any questions or suggestions, feel free to leave a comment below.

Thanks for reading, and see you next time!

References