DEV Community

junian
junian

Posted on • Originally published at junian.net on

Installing Multiple .NET Versions on macOS with Homebrew

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.

However, 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.

Solution

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

Using it is simple.

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
Enter fullscreen mode Exit fullscreen mode

Once that's done, tap my repository:

brew tap junian/homebrew-dotnet
Enter fullscreen mode Exit fullscreen mode

For example, to install the .NET 10 SDK:

brew install dotnet-sdk@10.0
Enter fullscreen mode Exit fullscreen mode

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

Let's consider a scenario:

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
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

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

brew uninstall dotnet-sdk@6.0
Enter fullscreen mode Exit fullscreen mode

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

Top comments (0)