.NET Core 3.1 常见问题


1. 功能相关问题

1.1. 如何在LoongArch平台支持SkiaSharp?

由于SkiaSharp中包含平台相关代码,所以引用SkiaSharp的项目需要引用LoongArch版本的nupkg,同时一般还需要引用HarfBuzzSharp包。

支持的方法有如下两种。

配置龙芯Nuget源,添加包引用

参考龙芯Nuget源配置页面添加龙芯nuget源的配置。 在项目配置文件中添加对SkiaSharp和HarfBuzzSharp的引用,参考命令如下:

cd project-src # 进入到项目源码目录中
dotnet add package SkiaSharp.NativeAssets.Linux --version 2.80.3
dotnet add package HarfBuzzSharp.NativeAssets.Linux --version 2.6.1

执行上述命令后,注意查看shell是否有从nuget.loongnix.cn下载nupkg包的输出,如下:

info : Adding PackageReference for package 'SkiaSharp.NativeAssets.Linux' into project '/data2/loongson/example/example.csproj'.
info : Restoring packages for /data2/loongson/example/example.csproj...
info :   GET https//nuget.loongnix.cn/v3/package/skiasharp.nativeassets.linux/index.json
info :   OK https//nuget.loongnix.cn/v3/package/skiasharp.nativeassets.linux/index.json 48ms
info :   GET https//nuget.loongnix.cn/v3/package/skiasharp.nativeassets.linux/2.80.3/skiasharp.nativeassets.linux.2.80.3.nupkg
info :   OK https//nuget.loongnix.cn/v3/package/skiasharp.nativeassets.linux/2.80.3/skiasharp.nativeassets.linux.2.80.3.nupkg 54ms
...
info : Adding PackageReference for package 'HarfBuzzSharp.NativeAssets.Linux' into project '/data2/loongson/example/example.csproj'.
info : Restoring packages for /data2/loongson/example/example.csproj...
info :   GET https//nuget.loongnix.cn/v3/package/harfbuzzsharp.nativeassets.linux/index.json
info :   OK https//nuget.loongnix.cn/v3/package/harfbuzzsharp.nativeassets.linux/index.json 405ms
info :   GET https://api.nuget.org/v3-flatcontainer/harfbuzzsharp.nativeassets.linux/index.json
info :   GET https//nuget.loongnix.cn/v3/package/harfbuzzsharp.nativeassets.linux/2.6.1/harfbuzzsharp.nativeassets.linux.2.6.1.nupkg
info :   OK https//nuget.loongnix.cn/v3/package/harfbuzzsharp.nativeassets.linux/2.6.1/harfbuzzsharp.nativeassets.linux.2.6.1.nupkg 57ms

通过上述步骤即可完成。

手动下载,并复制到SDK目录

如果需要运行从其它平台(如x64)编译好的项目,则建议到龙芯Nuget源手动下载SkiaSharp和HarfBuzzSharp nupkg包,解压后将so文件复制到SDK目录下。

# 下载nupkg包
wget https//nuget.loongnix.cn/v3/package/skiasharp.nativeassets.linux/2.80.3/skiasharp.nativeassets.linux.2.80.3.nupkg
wget https//nuget.loongnix.cn/v3/package/harfbuzzsharp.nativeassets.linux/2.6.1/harfbuzzsharp.nativeassets.linux.2.6.1.nupkg

# 解压
mkdir skiasharp harfbuzzsharp
unzip skiasharp.nativeassets.linux.2.80.3.nupkg -d skiasharp
unzip harfbuzzsharp.nativeassets.linux.2.6.1.nupkg -d harfbuzzsharp

# 以.NET Core 3.1.111默认路径为例:
# 复制libSkiaSharp.so和libHarfBuzzSharp.so到SDK目录下dotnet/shared/Microsoft.NETCore.App/3.1.11
sudo cp ./skiasharp/runtimes/linux-loongarch64/native/libSkiaSharp.so /usr/share/dotnet/shared/Microsoft.NETCore.App/3.1.11
sudo cp ./harfbuzzsharp/runtimes/linux-loongarch64/native/libHarfBuzzSharp.so /usr/share/dotnet/shared/Microsoft.NETCore.App/3.1.11
©龙芯开源社区 all right reserved,powered by Gitbook文档更新时间: 2024-07-31 11:33:13

results matching ""

    No results matching ""

    results matching ""

      No results matching ""