Search code examples
macos.net-corehomebrew

Multiple versions of .Net Core on Macos with brew


I have been searching for a while but I haven't found anything accurate in 2019 about that how can I have multiple versions from .Net Core on Mac. My use case is that, I use .Net Core 2.2 for active development, and I'd like to play with .Net Core 3 and the goodness it has now like Razor Components and Blazor stuff.

I found articles about how .Net Core multiple version can live on the same system on Windows, which is awesome. But, Mac is not Windows (luckily, and unfortunately), and I'd like to use brew as package manager which is dealing with managing versions instead of me. If it is possible, I don't want to move out form brew zone.

I haven't found information about that how brew can help me out, rather it throws an error message saying that it will overwrite dotnet command.

mbp2017 ➜  ~ brew search dotnet
==> Casks
dotnet                                      dotnet-preview                              dotnet-sdk ✔                                dotnet-sdk-preview
mbp2017 ➜  ~ dotnet --info
.NET Core SDK (reflecting any global.json):
 Version:   2.2.105
 Commit:    7cecb35b92

Runtime Environment:
 OS Name:     Mac OS X
 OS Version:  10.14
 OS Platform: Darwin
 RID:         osx.10.14-x64
 Base Path:   /usr/local/share/dotnet/sdk/2.2.105/

Host (useful for support):
  Version: 2.2.3
  Commit:  6b8ad509b6

.NET Core SDKs installed:
  2.2.105 [/usr/local/share/dotnet/sdk]

.NET Core runtimes installed:
  Microsoft.AspNetCore.All 2.2.3 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.App 2.2.3 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 2.2.3 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]

To install additional .NET Core runtimes or SDKs:
  https://aka.ms/dotnet-download
mbp2017 ➜  ~ brew cask install dotnet-sdk-preview
Error: Cask 'dotnet-sdk-preview' conflicts with 'dotnet-sdk'.
➜  ~ dotnet --list-sdks
2.2.105 [/usr/local/share/dotnet/sdk]

I found articles about DNVM, but turned out that it was something around .Net Core 1.x, since then seems not usable.

How is possible to have multiple versions from .Net Core for example using brew? If brew can't do this, then what is the suggested way?


Solution

  • It seems brew cannot help, or at least, I haven't find a solution. However, just downloading and installing packages from .Net Core websites solves the problem. Installing both version SDKS, you will have both.

    ➜  ~ dotnet --info
    .NET Core SDK (reflecting any global.json):
     Version:   3.0.100-preview3-010431
     Commit:    d72abce213
    
    Runtime Environment:
     OS Name:     Mac OS X
     OS Version:  10.14
     OS Platform: Darwin
     RID:         osx.10.14-x64
     Base Path:   /usr/local/share/dotnet/sdk/3.0.100-preview3-010431/
    
    Host (useful for support):
      Version: 3.0.0-preview3-27503-5
      Commit:  3844df9537
    
    .NET Core SDKs installed:
      2.2.105 [/usr/local/share/dotnet/sdk]
      3.0.100-preview3-010431 [/usr/local/share/dotnet/sdk]
    
    .NET Core runtimes installed:
      Microsoft.AspNetCore.All 2.2.3 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.All]
      Microsoft.AspNetCore.App 2.2.3 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
      Microsoft.AspNetCore.App 3.0.0-preview3-19153-02 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
      Microsoft.NETCore.App 2.2.3 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
      Microsoft.NETCore.App 3.0.0-preview3-27503-5 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
    
    To install additional .NET Core runtimes or SDKs:
      https://aka.ms/dotnet-download