带有brew的Macos上的.Net Core的多个版本

时间:2019-03-27 22:11:45

标签: macos .net-core homebrew

我已经搜索了一段时间,但是在2019年我没有发现关于如何从Mac上的.Net Core获得多个版本的任何准确信息。我的用例是,我使用.Net Core 2.2进行主动开发,并且我想使用.Net Core 3及其现在的优点,如Razor Components和Blazor之类。

我找到了有关.Net Core多个版本如何在Windows上的同一系统上运行的文章。但是,Mac不是Windows(幸运的是,不幸的是,不是Windows),我想用brew作为软件包管理器,而不是我来管理版本。如果可能的话,我不想离开酿造区。

我尚未找到有关brew如何帮助我的信息,而是抛出一条错误消息,提示它将覆盖dotnet命令。

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]

我找到了有关DNVM的文章,但事实证明它与.Net Core 1.x有关,从那时起似乎不可用。

例如使用brew,如何从.Net Core获得多个版本?如果brew无法做到这一点,那么建议的方法是什么?

4 个答案:

答案 0 :(得分:16)

聚会晚了一点,但是您现在可以用dotnet-sdk-versions水龙头来完成此操作。

您可以在这里找到它:https://github.com/isen-ng/homebrew-dotnet-sdk-versions

brew tap isen-ng/dotnet-sdk-versions
brew cask install dotnet-sdk-2.2.100

dotnet --list-sdks

免责声明:我两天前写了水龙头

答案 1 :(得分:1)

dotnet core 3预览有一个容器,您可以使用以下命令安装最新的预览

$ brew cask install dotnet-sdk-preview

安装后,您可以看到

$ dotnet --info 

dotnet --info
.NET Core SDK (reflecting any global.json):
 Version:   3.0.100-preview5-011568
 Commit:    b487ff10aa

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-preview5-011568/

Host (useful for support):
  Version: 3.0.0-preview5-27626-15
  Commit:  61f30f5a23

.NET Core SDKs installed:
  2.1.403 [/usr/local/share/dotnet/sdk]
  2.2.101 [/usr/local/share/dotnet/sdk]
  2.2.102 [/usr/local/share/dotnet/sdk]
  3.0.100-preview5-011568 [/usr/local/share/dotnet/sdk]

.NET Core runtimes installed:
  Microsoft.AspNetCore.All 2.1.5 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.All 2.2.0 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.All 2.2.1 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.App 2.1.5 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 2.2.0 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 2.2.1 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 3.0.0-preview5-19227-01 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 2.1.5 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.2.0 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.2.1 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 3.0.0-preview5-27626-15 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]

To install additional .NET Core runtimes or SDKs:
  https://aka.ms/dotnet-download

答案 2 :(得分:0)

看来Brew无法帮助您,或者至少我没有找到解决方案。但是,仅从.Net Core网站下载和安装程序包即可解决此问题。安装两个版本的SDKS,您将同时拥有。

➜  ~ 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

答案 3 :(得分:0)

这对我有用:

brew cask install \
  https://raw.githubusercontent.com/Homebrew/homebrew-cask/master/Casks/dotnet-sdk.rb