Running Multiple .NET Versions In MacOS OSX
[.NET, C#]
With .NET 9 released the other day, you might find not all your tools and libraries support .NET 9.
If you are on OSX, this presents some challenges, as using the .NET Installer does not allow you to run more than one version of the .NET SDK.
However, there is a solution to this.
First, you need to install and setup Homebrew for OSX.
Next you need to setup the cask that has the various .NET SDK Versions. This is done using this command:
brew tap isen-ng/dotnet-sdk-versions
Next, you can proceed to install the .NET version you require
brew install --cask <version>
The list of versions available is as follows, as of 22 November 2022:
Version | SDK |
---|---|
dotnet-sdk9 | 9.0.100 |
dotnet-sdk8 | 8.0.404 |
dotnet-sdk7 | 7.0.410 |
dotnet-sdk6 | 6.0.428 |
dotnet-sdk5 | 5.0.408 |
dotnet-sdk3 | 3.1.426 |
dotnet-sdk2 | 2.2.402 |
Remember, .NET 7 going backwards are out of support!
So, for instance, to install .NET 9 you would do so as follows:
brew install --cask dotnet-sdk9
And then to install .NET 8
brew install --cask dotnet-sdk8
Once done you can verify both are installed by running the following command
dotnet --list-sdks
You should see the following output
dotnet --list-sdks
8.0.404 [/usr/local/share/dotnet/sdk]
9.0.100 [/usr/local/share/dotnet/sdk]
Happy hacking!