Linux中使用原生Wpf之Avalonia

快速开始

新建 avalonia.mvvm 项目
getting-started

#安装Avalonia.Templates
dotnet new install Avalonia.Templates
#查看已经安装的模板
dotnet new list|grep Avalonia
#创建项目
dotnet new avalonia.mvvm -o tutu -n tutu
cd tutu
dotnet run

图标与启动项

<!--图标与启动项-->
<ItemGroup>
    <Content Include="tutu.png" CopyToPublishDirectory="PreserveNewest">
        <LinuxPath>/usr/share/icons/tutu.png</LinuxPath>
    </Content>
    <Content Include="tutu.desktop" CopyToPublishDirectory="PreserveNewest">
        <LinuxPath>/usr/share/applications/tutu.desktop</LinuxPath>
    </Content>
</ItemGroup>

tutu.desktop

[Desktop Entry]
X-Deepin-CreatedBy=com.deepin.dde.daemon.Launcher
X-Deepin-AppID=tutu
Version=1.0.1
Encoding=UTF-8
Name=tutu
Comment=tutu test Software
Comment[zh_CN]=tutu测试软件
Exec=/usr/share/tutu/tutu
Icon=/usr/share/icons/tutu.png
GenericName=tutu Remote Control Software
GenericName[zh_CN]=tutu测试软件
keywords=tutu
Categories=Network;RemoteControl;
Type=Application
Terminal=false

vs中记得安装扩展

avalonia 打包

打包deb安装文件

bin\Debug\net6.0\runtimes 目录下有各种对应环境名称linux-x64

#安装 dotnet-deb 
dotnet tool install --global dotnet-deb
#查看已安装的tool
dotnet tool list -g

#到tutu.csproj所在目录
dotnet deb install
dotnet restore -r linux-x64

dotnet build tutu.csproj /t:CreateDeb /p:TargetFramework=net6.0 /p:RuntimeIdentifier=linux-x64 /p:Configuration=Release

#编译完成后再目录 bin\Release\net6.0\linux-x64 下生成 tutu.1.0.0.linux-x64.deb 安装包

运行效果

posted @ 2023-01-17 23:18  ddrsql  阅读(1750)  评论(0编辑  收藏  举报