参与贡献

编辑此文档

翻译文档,或在您的计算机上打开完整项目。

在您选择提交工作成果之前,不会发布任何内容。

创建安装程序

将应用程序打包以供分发

概述

为所有平台上的 Wails 应用程序创建专业的安装程序。

各平台安装程序

NSIS 安装程序

bash
# Install NSIS
# Download from: https://nsis.sourceforge.io/

# Create installer script (installer.nsi)
makensis installer.nsi

installer.nsi:

nsis
!define APPNAME "MyApp"
!define VERSION "1.0.0"

Name "${APPNAME}"
OutFile "MyApp-Setup.exe"
InstallDir "$PROGRAMFILES\${APPNAME}"

Section "Install"
    SetOutPath "$INSTDIR"
    File "build\bin\myapp.exe"
    CreateShortcut "$DESKTOP\${APPNAME}.lnk" "$INSTDIR\myapp.exe"
SectionEnd

WiX Toolset

用于创建 MSI 安装程序的替代方案。

自动打包

使用 GoReleaser

yaml
# .goreleaser.yml
project_name: myapp

builds:
  - binary: myapp
    goos:
      - windows
      - darwin
      - linux
    goarch:
      - amd64
      - arm64

archives:
  - format: zip
    name_template: "{{ .ProjectName }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}"

nfpms:
  - formats:
      - deb
      - rpm
    vendor: Your Company
    homepage: https://example.com
    description: My Application

最佳实践

✅ 应做

  • 在所有平台上进行代码签名
  • 包含版本信息
  • 创建卸载程序
  • 测试安装流程
  • 提供清晰的文档

❌ 不应做

  • 不要跳过代码签名
  • 不要忘记配置文件关联
  • 不要硬编码路径
  • 不要跳过测试

后续步骤

编辑页面

最后更新: