m1 mac 安装dotnetcore3.1、net6

发布时间 2023-03-30 17:24:16作者: kele-cc

.net6开始,微软提供了arm版本的SDK。visual studio for mac安装 .net6、.net7也是arm版本的。armx64版本安装的路径不同

arm路径:/usr/local/share/dotnet
x64路径:/usr/local/share/dotnet/x64

由于安装路径的不同会导致即使安装了dotnetcore3.1net6的时候,在启动dotnetcore3.1项目的时候也会提示找不到包。这时候就要切换启动程序dotnet

1. net6

Jetbrain Rider

image

MSBuild version路径:/usr/local/share/dotnet/sdk/7.0.202/MSBuild.dll 这里选arm最高版本的SDK包

Visual Studio for Mac

工具 -> 首选项

image

2.dotnetcore3.1

JetBrain Rider

image

MSBuild version路径:/usr/local/share/dotnet/x64/sdk/3.1.426/MSBuild.dll 这里选x64最高版本的SDK包

Visual Studio for Mac

工具 -> 首选项

image

注:x64能在m1上运行是苹果做了转译操作。猜测:这个过程需要时间。浏览器运行起来了,转译还没完成,就会出现这种情况。要么换个浏览器访问,要么清除浏览器缓存再访问,就可以了。

image

参考文档:https://learn.microsoft.com/zh-cn/dotnet/core/install/macos#download-and-manually-install