命令行可以打包,同样命令通过golang调用则不能打包

  • Creator 版本:2.4.4

  • 目标平台:在windows下,通过golang调用打包命令,编译android或ios包

  • 重现方式:在windows下,通过golang调用打包命令,编译android或ios包
    出现的返回是:(可以看到已经正确接受参数)
    2023/03/03 20:37:34
    2023/03/03 20:37:34 (node:39912) [DEP0106] DeprecationWarning: crypto.createDecipher is deprecated.
    2023/03/03 20:37:34 ===== Initializing Editor =====
    2023/03/03 20:37:34 arguments:
    2023/03/03 20:37:34 --path D:\BreezGirlPublishDir/Repository/Fugen
    2023/03/03 20:37:34 --build platform=android;debug=true
    2023/03/03 20:37:34

2023/03/03 20:37:35 Load profile failed: local://settings.json
此时只能看到编辑器启动,未打开工程的状态。

但如果用命令调用:(可以对比上面的参数)
C:\Users\wildf>cmd /c C:\Project\skybox\Creator\2.4.4\CocosCreator.exe --path “D:\BreezGirlPublishDir/Repository/Fugen” --build “platform=android;debug=true”

(node:37988) [DEP0106] DeprecationWarning: crypto.createDecipher is deprecated.
{ Error: EPERM: operation not permitted, unlink ‘C:\Users\wildf.CocosCreator\logs\CocosCreator.log’
at Object.unlinkSync (fs.js:1008:3)
at App. (C:\Project\skybox\Creator\2.4.4\resources\app.asar\editor-framework\index.js:1:3223)
at App.emit (events.js:199:15)
at App.EventEmitter.emit (domain.js:469:20)
at App.topLevelDomainCallback (domain.js:124:23)
errno: -4048,
syscall: ‘unlink’,
code: ‘EPERM’,
path: ‘C:\Users\wildf\.CocosCreator\logs\CocosCreator.log’ }
===== Initializing Editor =====
arguments:
–path
D:\BreezGirlPublishDir/Repository/Fugen
–build
platform=android;debug=true

[37988] Load ~/.CocosCreator/settings.json
[37988] Initializing Asset Database
[37988] checking language setting…
[37988] Language: zh
Load profile failed: local://settings.json
Load profile failed: local://settings.json
Load profile failed: local://settings.json
[37988] protocol editor-framework registered
[37988] protocol app registered
[37988] protocol theme registered
[37988] protocol packages registered
[37988] protocol uuid registerred
[37988] protocol db registerred
[37988] protocol thumbnail registerred
[37988] protocol unpack registerred
[37988] protocol disable-commonjs registerred
[37988] connected!
[37988] Check project D:\BreezGirlPublishDir\Repository\Fugen
[37988] Initializing project D:\BreezGirlPublishDir\Repository\Fugen
[37988] adapters loaded
[37988] asset-db-debugger loaded
[37988] fb-audience-network loaded
[37988] fb-live-stream loaded
[37988] google-play-instant loaded
[37988] jsb-adapter loaded
[37988] package-manager loaded
[37988] runtime-adapters loaded
[37988] runtime-dev-tools loaded
[37988] ui-kit-preview-extra loaded
[37988] ui-kit-preview loaded
[37988] alipay-minigame loaded
[37988] assets loaded
[37988] baidugame-opendata loaded
[37988] baidugame loaded
[37988] builder loaded
[37988] bytedance-opendata loaded
[37988] bytedance loaded
[37988] channel-upload-tools loaded
[37988] cloud-function loaded
Cocos Service Version 0.6.7
[37988] cocos-services loaded
[37988] console loaded
[37988] curve-editor loaded
[37988] fb-instant-games loaded
[37988] game-window loaded
[37988] google-instant-games loaded
[37988] hierarchy loaded
[37988] huawei-agc loaded
[37988] huawei-runtime loaded
[37988] inspector loaded
[37988] cpk-publish loaded
[37988] keystore loaded
[37988] link-sure-runtime loaded
[37988] node-library loaded
[37988] open-recent-items loaded
[37988] oppo-runtime loaded
[37988] package-asset loaded
[37988] preferences loaded
[37988] project-importer loaded
[37988] project-settings loaded
[37988] qtt-runtime loaded
[37988] scene loaded
[37988] simulator-debugger loaded
[37988] sprite-editor loaded
[37988] store loaded
[37988] timeline loaded
[37988] vivo-runtime loaded
[37988] wechatgame-opendata loaded
[37988] wechatgame loaded
[37988] xiaomi-runtime loaded
[37988] im-plugin loaded
Native extraction module not loaded, msgpackr will still run, but with decreased performance. No native build was found for platform=win32 arch=x64 runtime=electron abi=70 uv=1 libc=glibc node=12.0.0 electron=5.0.8
loaded from: D:\BreezGirlPublishDir\Repository\Fugen\node_modules\msgpackr-extract and package: msgpackr-extract-win32-x64

[37988] export-scene loaded
[37988] hot-update loaded
(node:37988) [DEP0005] DeprecationWarning: Buffer() is deprecated due to security and usability issues. Please use the Buffer.alloc(), Buffer.allocUnsafe(), or Buffer.from() methods instead.
[37988] 寮曟搸缂栬瘧涓紝棣栨缂栬瘧闇€瑕佽緝闀挎椂闂达紝璇风◢绛夈€?
此时可以正常打包,编辑器界面也没有显示。

请问应该如何解决呢?我是否有什么地方没处理到的。

经研究,发现,如果使用如下格式传递命令,就可以正常工作。求官方解答

C:\Project\skybox\Creator\2.4.4\CocosCreator.exe --path=D:\BreezGirlPublishDir/Repository/Fugen --build=“platform=android;debug=true”

特别注意,如果使用 --path=“projectPath” 格式,会导致运行时报路径包含非法字符,原因是引号也被当做路径字符串的一部分。因此路径不要有空格。

1赞

参考下这个帖子,你这个双引号应该是中文的,如果是你使用的命令肯定有问题。还有你这个日志最后打印的是乱码,可以参考帖子里面的,修改修改控制配置。

打文档的时候,错误使用了中文引号。做代码的时候,没发生这种低级错误。

我在这用截图,避免有任何的偏差


这个是传递的build参数。
然后解析到的参数是这样:
image
我们继续看,引擎在编译时用的参数:

我们现在继续看path参数的反应
image
加上引号
image



在这个位置就不能往下执行了。
原本后面的步骤应该是
protocol unpack registerred
protocol disable-commonjs registerred
connected!

正常版本:
image