# [Ubuntu 22.04安装.net 8](https://learn.microsoft.com/zh-cn/dotnet/core/install/linux-ubuntu-2204) ```sh # 更新包 sudo apt-get update # 安装.net 8 sudo apt-get install -y dotnet-sdk-8.0 ``` # 运行 ```sh #恢复依赖 dotnet restore #编译项目 dotnet build # 查看版本列表 dotnet --list-sdks # 发布项目 dotnet publish -c Release # AOT编译 dotnet publish -c Release -r linux-x64 -p:PublishAot=true -p:EnableAotAnalyzer=true -p:IlcOptimizationPreference=speed -v diag -o "/disk/Public/miaoyu/Public/aot/" dotnet publish -c Release -r linux-x64 -p:PublishAot=true -p:EnableAotAnalyzer=true -p:IlcOptimizationPreference=speed -v diag -o "/disk/public/" # docker打包镜像 docker build -t miaoyu:dev-1.2.6 --build-arg VERSION=1.2.6 --build-arg TARGET=dev -f 2-api/HuanMeng.MiaoYu.WebApi/Dockerfile . # -t webapi:dev-0.0.1 指定了镜像的名称为 miaoyu 标签为 dev-0.0.1 # -f 2-api/HuanMeng.MiaoYu.WebApi/Dockerfile 指定了 Dockerfile 的路径。 # . 表示当前目录作为 Docker 构建的上下文。 # docker run -d -p 90:90 --name webapi miaoyu:dev-1.2.5 ```