Skip to content

feat#扩展一下现在系统的发布功能 #71

Closed as not planned
Closed as not planned

Description

@gaoconggit

需要支持单文件发布和AOT发布还有自包含发布
@claude

Activity

  1. claude commented on Oct 27, 2025

    @claude

    Claude finished @gaoconggit's task —— View job • claude/issue-71-20251027-1547 • Create PR ➔


    Todo List

    • Analyze current build system and scripts
    • Understand existing project configurations
    • Create comprehensive publish scripts for Windows (PowerShell)
    • Create comprehensive publish scripts for macOS/Linux (Bash)
    • Add single-file publish support
    • Add AOT (Ahead-of-Time) publish support
    • Add self-contained publish support
    • Create documentation
    • Commit and push changes

    实现完成 ✅

    我已成功为 SharpPad 桌面应用添加了完整的发布功能支持,包括您要求的所有三种发布模式。

    新增文件

    1. publish-desktop.ps1 - PowerShell 跨平台发布脚本
    2. publish-desktop.sh - Bash 发布脚本(Unix 系统)
    3. PUBLISH.md - 详细的发布指南文档

    支持的发布模式

    1. 单文件发布 (SingleFile)

    将整个应用程序打包成一个可执行文件,包含所有依赖项。

    # Windows
    .\publish-desktop.ps1 -PublishMode SingleFile
    
    # macOS/Linux
    ./publish-desktop.sh singlefile

    2. AOT 编译 (AOT - Ahead-of-Time)

    原生编译,提供最佳启动速度和性能。

    # Windows
    .\publish-desktop.ps1 -PublishMode AOT
    
    # macOS/Linux
    ./publish-desktop.sh aot

    3. 自包含发布 (SelfContained)

    包含 .NET 运行时,目标机器无需安装 .NET。

    # Windows
    .\publish-desktop.ps1 -PublishMode SelfContained
    
    # macOS/Linux
    ./publish-desktop.sh selfcontained

    主要特性

    • ✅ 自动检测平台和架构(x64/ARM64)
    • ✅ 支持跨平台构建(Windows、macOS、Linux)
    • ✅ 支持所有主流架构(win-x64、win-arm64、osx-x64、osx-arm64、linux-x64、linux-arm64)
    • ✅ 自动清理不需要的运行时文件
    • ✅ 输出目录优化
    • ✅ 详细的彩色日志输出
    • ✅ 完整的错误处理

    使用示例

    # 为当前平台创建单文件版本
    ./publish-desktop.sh singlefile
    
    # 为 Apple Silicon Mac 创建 AOT 版本
    ./publish-desktop.sh aot osx-arm64
    
    # 为 Windows x64 创建自包含版本
    .\publish-desktop.ps1 -PublishMode SelfContained -Runtime win-x64

    文档

    详细的使用文档请参考 PUBLISH.md,包含:

    • 每种发布模式的详细说明
    • 使用场景和性能对比
    • 完整的参数说明
    • 常见问题解答
    • 高级用法和 CI/CD 集成示例

    创建 Pull Request


    | Branch: claude/issue-71-20251027-1547

  2. added a commit that references this issue on Oct 27, 2025
    2531081
  3. gaoconggit commented on Oct 29, 2025

    @gaoconggit
    OwnerAuthor
    Image 发布指的系统内的功能
  4. gaoconggit commented on Oct 29, 2025

    @gaoconggit
    OwnerAuthor
  5. claude commented on Oct 29, 2025

    @claude

    Claude finished @gaoconggit's task —— View job • claude/issue-71-20251029-0324 • Create PR ➔


    实现完成 ✅

    我已成功扩展SharpPad的系统内部发布功能,现在支持四种发布模式:

    新增功能

    发布模式选择器
    在"发布"按钮旁边添加了下拉菜单,用户可以选择:

    1. 自包含 (默认) - 包含 .NET 运行时,可在未安装 .NET 的机器上运行
    2. 单文件 - 将应用和所有依赖项打包成单个可执行文件
    3. AOT编译 - 原生提前编译,提供最佳启动速度和性能
    4. 依赖框架 - 不包含运行时,体积更小但需要目标机器安装 .NET

    技术实现

    前端改动

    • index.html:84-89 - 添加发布模式选择器 UI
    • runner.js:64,735,770,788 - 读取选中的模式并传递给后端

    后端改动

    • ExeBuildRequest.cs:16 - 添加 PublishMode 属性
    • CodeRunController.cs:268,280 - 将发布模式传递给 CodeRunner
    • CodeRunner.cs:2558,2570,2583 - 更新方法签名接受发布模式参数
    • CodeRunner.cs:2636-2647 - 根据模式添加相应的 MSBuild 属性:
      • AOT: PublishAot=true + InvariantGlobalization=true
      • 单文件: PublishSingleFile=true + SelfContained=true
    • CodeRunner.cs:2755-2777 - 根据模式构建不同的 dotnet publish 命令参数

    使用方法

    1. 在 SharpPad 中编写 C# 代码
    2. 点击"发布"按钮旁的下拉菜单选择发布模式
    3. 点击"发布"按钮
    4. 系统会使用选定的模式编译并打包应用
    5. 完成后自动下载发布包

    发布模式对比

    模式 启动速度 文件大小 运行时依赖 适用场景
    自包含 中等 大 无 通用分发
    单文件 中等 大(单文件) 无 便携分发
    AOT 最快 中等 无 性能关键应用
    依赖框架 快 最小 需要.NET 已有.NET环境

    构建成功

    所有更改已通过编译测试(Release 构建成功),准备就绪可以使用。


  6. added a commit that references this issue on Oct 29, 2025
    c57de46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions