Avalonia + .NET6 发布到银河麒麟V10桌面系统总结

1. 银河麒麟V10桌面系统配置

A

2. 项目架构

项目中Avalonia 最开始用的是11版本,打包成deb的时候遇到太多问题没解决,就把Avalonia 退回到了10版本。

3. 准备发布工作,创建desktop文件

文件内容:

[Desktop Entry]
Name=SerialDebugAssistant
Type=Application
Exec=/usr/share/SerialDebugAssistant/SerialDebugAssistant
Icon=/usr/share/icons/ylyt.png

4. 编辑项目文件,添加以下内容

    <ItemGroup>
        <Content Include="ylyt.png" CopyToPublishDirectory="PreserveNewest">
            <LinuxPath>/usr/share/icons/ylyt.png</LinuxPath>
        </Content>
        <Content Include="SerialDebugAssistant.desktop" CopyToPublishDirectory="PreserveNewest">
            <LinuxPath>/usr/share/applications/SerialDebugAssistant.desktop</LinuxPath>
        </Content>
    </ItemGroup>

5.安装.net 打包deb工具

命令:dotnet tool install --global dotnet-deb

6.进入项目文件夹cmd

7.依次输入以下命令

   1. 将项目的目标运行时还原为linux-arm64,命令:dotnet restore -r linux-arm64

注:CPU架构不是arm 64位的话,命令:dotnet restore -r linux-x64

2.在项目中安装打包工具,命令:dotnet rpm install

注:CPU架构不是arm 64位的话,命令可能是:dotnet deb install。

异常:下面的异常是因为我的电脑没安装.net 6 SDK导致的,dotnet deb install这个工具在github官网看到好像只支持到.net 6。

3.执行打包发布命令:dotnet msbuild SerialDebugAssistant.csproj /t:CreateDeb /p:TargetFramework=net6.0 /p:RuntimeIdentifier=linux-arm64 /p:Configuration=Release

注:CPU架构不是arm 64位的话,命令:dotnet msbuild SerialDebugAssistant.csproj /t:Createdeb /p:TargetFramework=net6.0 /p:RuntimeIdentifier=linux-x64 /p:Configuration=Release

SerialDebugAssistant.csproj:项目名称

/Createdeb:创建deb安装包,ubuntu系统使用CreateRpm 

TargetFramework:项目框架版本

RuntimeIdentifier=linux-arm64:CPU架构

Configuration:打包后的文件位置,项目的bin目录

8.deb安装包拷贝到银河麒麟系统

9. 麒麟系统进入deb安装包目录,打开终端

10. 切换到root账户

命令:su root,输入root账户密码。银河麒麟安装软件需要root权限。

11.安装deb

命令:dpkg -i deb安装包名称

12.安装完成后,启动程序

1. 直接输入程序名称启动,这样启动的话,程序报错会输出错误消息。

2. 向windows系统一样双击打开或开始菜单中找到打开。

13.程序启动异常:default font familyname can't be null,这是提示缺少默认字体,需要指定字体

 解决办法:

     1. 拷贝windows系统自带的微软雅黑到如下路径 /usr/share/fonts/chinese/msyh.ttc

      2. 运行fc-cache -f -v 命令,更新字体缓存

       3. 修改Program.cs

class Program {

    [STAThread]
    public static void Main(string[] args) => BuildAvaloniaApp()
        .StartWithClassicDesktopLifetime(args);

    // Avalonia configuration, don't remove; also used by visual designer.
    public static AppBuilder BuildAvaloniaApp()
    {
        FontManagerOptions options = new FontManagerOptions()
        {
            DefaultFamilyName = "Microsoft YaHei"
        };

        return AppBuilder.Configure<App>()
            .UsePlatformDetect()
            .LogToTrace()
            .UseReactiveUI().With(options);
    }
}

4.再重新打包deb

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值