如何在MacOS上安装ASP.NET Core 2.0?

时间:2018-10-07 20:16:16

标签: c# asp.net-core

我试图在Mac上运行ASP.NET Core 2.0应用,但由于以下原因,它无法构建:

Package Microsoft.AspNetCore.All 2.1.5 is not compatible with netcoreapp2.0 (.NETCoreApp,Version=v2.0). Package Microsoft.AspNetCore.All 2.1.5 supports: netcoreapp2.1 (.NETCoreApp,Version=v2.1)

我已经安装了Visual Studio for Mac(社区)v.6.8.2。当我运行dotnet --info时,我得到:

.NET Core SDK (reflecting any global.json):
 Version:   2.1.302
 Commit:    9048955601

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

Host (useful for support):
  Version: 2.1.2
  Commit:  811c3ce6c0

.NET Core SDKs installed:
  2.0.0 [/usr/local/share/dotnet/sdk]
  2.1.4 [/usr/local/share/dotnet/sdk]
  2.1.301 [/usr/local/share/dotnet/sdk]
  2.1.302 [/usr/local/share/dotnet/sdk]

.NET Core runtimes installed:
  Microsoft.AspNetCore.All 2.1.1 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.All 2.1.2 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.App 2.1.1 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 2.1.2 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 1.0.5 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.0.0 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.0.5 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.0.9 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.1.1 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.1.2 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]

我看到我没有Microsoft.AspNetCore.All 2.0。*运行时,但是我不知道如何安装它。我已经从此处下载了二进制文件:https://www.microsoft.com/net/download/dotnet-core/2.0,但是没有有关如何处理文件的说明。

我要构建/运行的应用程序在这里:https://github.com/Apress/pro-asp.net-core-mvc-2(文件夹“ 08-SportsStore / SportsStore”)。

1 个答案:

答案 0 :(得分:1)

编辑-完全误读了您的问题-看起来this是您需要的下载,特别是https://www.microsoft.com/net/download/thank-you/dotnet-runtime-2.0.9-macos-x64-asp.net-core-runtime-binaries

您可以通过编辑.csproj文件,使项目目标为netcoreapp2.1而不是netcoreapp2.0,

<PropertyGroup>
    <TargetFramework>netcoreapp2.1</TargetFramework>
</PropertyGroup>

您检查是否已安装2.1 SDK,但是使用该SDK可以定位到2.1以下的任何框架,包括2.0。

如果您确实希望您的应用程序使用2.0,则另一种选择是将aspnet软件包降级为2.0.x版本,例如2.0.9。您可以在nuget.org的Dependencies部分下查看每个软件包所需的框架版本。