nacos-group / nacos-sdk-csharp

This nacos csharp sdk
https://nacos-sdk-csharp.readthedocs.io
Apache License 2.0
415 stars 91 forks source link

.net core sdk 在 M1芯片的macOS 13.3.1 中获取不到配置值 #251

Open ZhaoBaoLin159753 opened 1 year ago

ZhaoBaoLin159753 commented 1 year ago

.net core sdk 在 M1芯片的macOS 13.3.1 中获取不到配置值,但是同样的代码在win下能获取到值

catcherwong commented 1 year ago

ref: #211

heqingpan commented 4 months ago

.net core sdk不支持m1芯片的原因是因为sdk grpc底层使用的是Grpc.Core,Grpc.Core不支持macOS arm64芯片。

Grpc.Core不支持macOS arm64的原因是因为:Grpc.Core依赖native动态库,然后Grpc.Core包中没有macOS arm64对应的动态库。(windows支持x86和x64,linux支持x64和arm64,macOS只支持x64)

解决方案:

  1. 联系Grpc.Core开发者,让其发布支持macOS arm64的新版本;目前Grpc.Core已不更新,其推荐使用grpc-dotnet。
  2. 使用grpc-dotnet替换Grpc.Core ,我在本地测试grpc-dotnet的例子,其打包出的结果不依赖native动态库,也就没有grpc-dotnet的问题。

我看 #258 也有讨论切换到grpc-dotnet,Grpc.Core已不更新,切换到grpc-dotnet的方案应该更合适一些。


Grpc.Core不支持macOS arm64,从应用发布结果就能看出来。

使用当前仓库的samples/App3例子,在samples/App3目录下执行发布命令dotnet publish,在 public目录下有runtimes native 动态库包,有5类动态库,不包含osx-arm64 。

发布包文件夹下具体的文件信息如下:

$ tree .
.
├── App3
├── App3.deps.json
├── App3.dll
├── App3.pdb
├── App3.runtimeconfig.json
├── App3.xml
├── Google.Protobuf.dll
├── Grpc.Core.Api.dll
├── Grpc.Core.dll
├── Microsoft.Extensions.DependencyModel.dll
├── Nacos.AspNetCore.dll
├── Nacos.AspNetCore.pdb
├── Nacos.AspNetCore.xml
├── Nacos.dll
├── Nacos.pdb
├── Nacos.xml
├── Newtonsoft.Json.dll
├── appsettings.Development.json
├── appsettings.json
├── runtimes
│   ├── linux-arm64
│   │   └── native
│   │       └── libgrpc_csharp_ext.arm64.so
│   ├── linux-x64
│   │   └── native
│   │       └── libgrpc_csharp_ext.x64.so
│   ├── osx-x64
│   │   └── native
│   │       └── libgrpc_csharp_ext.x64.dylib
│   ├── win-x64
│   │   └── native
│   │       └── grpc_csharp_ext.x64.dll
│   └── win-x86
│       └── native
│           └── grpc_csharp_ext.x86.dll
└── web.config