windows打包
安装
安装在上一篇文章里
关于electron-builder打包可以有两种方案:
- 打包成文件夹及绿色免安装:
electron-builder --dir(依赖winCodeSign)
2.打包成exe的安装包
electron-builder (依赖winCodeSign和nsis)
electron-builder有一些依赖包如 【winCodeSign】、【nsis】;在科学上网的情况下,直接执行命令就会自动处理相关依赖,但天朝基本不科学上网,所以会出现包安装超时等的一些情况,这个时候就需要手动安装:
1.第一步:下载wincodesign包 链接: https://github.com/electron-userland/electron-builder-binaries/releases
2.第二步:选择Source code (zip)下载并解压,里面已经包含nsis
3.第三步:在%LOCALAPPDATA%(C:\Users\Administrator\AppData\Local\electron-builder\Cache\winCodeSign)如果不存在就新建electron-builder\cache\
4.第四步:将Source code (zip)解压到第三步的目录下,根据错误提示的版本在对于的包下面新建对于的版本,并把文件移动到目录下,便可正常打包,如图:
mac打包
electron-builder --win --x64
运行以上命令会抛错误:
• electron-builder version=22.10.5 os=20.3.0
• writing effective config file=dist/builder-effective-config.yaml
• packaging platform=win32 arch=x64 electron=13.1.1 appOutDir=dist/win-unpacked
• Unpacking electron zip zipPath=undefined
• default Electron icon is used reason=application icon is not set
• downloading url=https://github.com/electron-userland/electron-builder-binaries/releases/download/wine-4.0.1-mac/wine-4.0.1-mac.7z size=19 MB parts=3
^C • canceling signal=interrupt
• cancelled by SIGINT
⨯ sha512 checksum mismatch, expected aCUQOyuPGlEvLMp0lPzb54D96+8IcLwmKTMElrZZqVWtEL1LQC7L9XpPv4RqaLX3BOeSifneEi4j9DpYdC1DCA==, got 1iqyfg0+72nqyW1/fDGvIoHUFVuANWYKMEBN3QCXuWb7o3L6Q5X2CxVx8ptFMiyasR9U+73kzxY84I4gihNHHA==
github.com/develar/app-builder/pkg/download.(*ActualLocation).concatenateParts
/Volumes/data/Documents/app-builder/pkg/download/ActualLocation.go:158
github.com/develar/app-builder/pkg/download.(*Downloader).DownloadResolved
/Volumes/data/Documents/app-builder/pkg/download/downloader.go:176
github.com/develar/app-builder/pkg/download.(*Downloader).DownloadNoRetry
/Volumes/data/Documents/app-builder/pkg/download/downloader.go:133
github.com/develar/app-builder/pkg/download.(*Downloader).Download
/Volumes/data/Documents/app-builder/pkg/download/downloader.go:112
github.com/develar/app-builder/pkg/download.DownloadArtifact
/Volumes/data/Documents/app-builder/pkg/download/artifactDownloader.go:107
github.com/develar/app-builder/pkg/wine.executeMacOsWine
/Volumes/data/Documents/app-builder/pkg/wine/wine.go:124
github.com/develar/app-builder/pkg/wine.ExecWine
/Volumes/data/Documents/app-builder/pkg/wine/wine.go:69
github.com/develar/app-builder/pkg/rcedit.editResources
/Volumes/data/Documents/app-builder/pkg/rcedit/rcedit.go:61
github.com/develar/app-builder/pkg/rcedit.ConfigureCommand.func1
/Volumes/data/Documents/app-builder/pkg/rcedit/rcedit.go:25
github.com/alecthomas/kingpin.(*actionMixin).applyActions
/Volumes/data/go/pkg/mod/github.com/alecthomas/kingpin@v2.2.6+incompatible/actions.go:28
github.com/alecthomas/kingpin.(*Application).applyActions
/Volumes/data/go/pkg/mod/github.com/alecthomas/kingpin@v2.2.6+incompatible/app.go:557
github.com/alecthomas/kingpin.(*Application).execute
/Volumes/data/go/pkg/mod/github.com/alecthomas/kingpin@v2.2.6+incompatible/app.go:390
github.com/alecthomas/kingpin.(*Application).Parse
/Volumes/data/go/pkg/mod/github.com/alecthomas/kingpin@v2.2.6+incompatible/app.go:222
main.main
/Volumes/data/Documents/app-builder/main.go:90
runtime.main
/usr/local/Cellar/go/1.15.5/libexec/src/runtime/proc.go:204
runtime.goexit
/usr/local/Cellar/go/1.15.5/libexec/src/runtime/asm_amd64.s:1374
github.com/develar/app-builder/pkg/download.(*Downloader).DownloadResolved
/Volumes/data/Documents/app-builder/pkg/download/downloader.go:178
github.com/develar/app-builder/pkg/download.(*Downloader).DownloadNoRetry
/Volumes/data/Documents/app-builder/pkg/download/downloader.go:133
github.com/develar/app-builder/pkg/download.(*Downloader).Download
/Volumes/data/Documents/app-builder/pkg/download/downloader.go:112
github.com/develar/app-builder/pkg/download.DownloadArtifact
/Volumes/data/Documents/app-builder/pkg/download/artifactDownloader.go:107
github.com/develar/app-builder/pkg/wine.executeMacOsWine
/Volumes/data/Documents/app-builder/pkg/wine/wine.go:124
github.com/develar/app-builder/pkg/wine.ExecWine
/Volumes/data/Documents/app-builder/pkg/wine/wine.go:69
github.com/develar/app-builder/pkg/rcedit.editResources
/Volumes/data/Documents/app-builder/pkg/rcedit/rcedit.go:61
github.com/develar/app-builder/pkg/rcedit.ConfigureCommand.func1
/Volumes/data/Documents/app-builder/pkg/rcedit/rcedit.go:25
github.com/alecthomas/kingpin.(*actionMixin).applyActions
/Volumes/data/go/pkg/mod/github.com/alecthomas/kingpin@v2.2.6+incompatible/actions.go:28
github.com/alecthomas/kingpin.(*Application).applyActions
/Volumes/data/go/pkg/mod/github.com/alecthomas/kingpin@v2.2.6+incompatible/app.go:557
github.com/alecthomas/kingpin.(*Application).execute
/Volumes/data/go/pkg/mod/github.com/alecthomas/kingpin@v2.2.6+incompatible/app.go:390
github.com/alecthomas/kingpin.(*Application).Parse
/Volumes/data/go/pkg/mod/github.com/alecthomas/kingpin@v2.2.6+incompatible/app.go:222
main.main
/Volumes/data/Documents/app-builder/main.go:90
runtime.main
/usr/local/Cellar/go/1.15.5/libexec/src/runtime/proc.go:204
runtime.goexit
/usr/local/Cellar/go/1.15.5/libexec/src/runtime/asm_amd64.s:1374
• Above command failed, retrying 3 more times
解决方法:
把downloading上的包下载下来放到
/Users/自己的电脑名称/Library/Caches/electron-builder/winCodeSign
如果还是不行就在拷贝一份到