powershell - Unity.exe 命令行构建需要 10 分钟,而编辑器只需不到一分钟

有时我在 Unity Editor 中构建我的项目,花费的时间不到一分钟。

但我也喜欢进行命令行构建,我注意到这需要十分钟。有什么办法可以解决这个问题,让它构建得更快吗?这是我的命令行的样子——我使用 powershell,以便在构建实际完成之前批处理文件不会继续。也许它与“-Wait”有关,但如果我不将其放在命令行中,则会在构建完成之前继续。

powershell -Command "Start-Process -FilePath C:\Users\me\source\Unity\Editors\2019.3.5f1\Editor\Unity.exe -ArgumentList '-batchmode -projectpath C:\Users\me\source\repos\MyProject -buildWindows64Player C:\mybuild\MyProject.exe -quit' -Wait" time /T

最佳答案

我在构建时通过仔细观察流程终于弄明白了这一点。事实证明,如果您有脚本,构建过程也会导致 VBCSCompiler.exe 运行。如果它是由 Unity 启动的,那么它将成为启动的进程树的一部分。它会保持打开十分钟,以防有更多工作要做。参见 here for more info .

因此,为了解决这个问题,我更改了我的代码:

powershell -Command "$unity = Start-Process -FilePath C:\Users\me\source\Unity\Editors\2019.3.5f1\Editor\Unity.exe -ArgumentList '-batchmode -projectpath C:\Users\me\source\repos\MyProject -buildWindows64Player C:\mybuild\MyProject.exe -quit' -PassThru; Start-Sleep -Seconds 3.0; Write-Host -NoNewLine 'Building...'; while ((Get-WmiObject -Class Win32_Process | Where-Object {$_.ParentProcessID -eq $unity.Id -and $_.Name -ne 'VBCSCompiler.exe'}).count -gt 0) { Start-Sleep -Seconds 1.0; Write-Host -NoNewLine '.' }; if (!$unity.HasExited) { Wait-Process -Id $unity.Id }; exit $unity.ExitCode"

https://stackoverflow.com/questions/65225251/

相关文章:

ios - 使用 NSPersistentCloudKitContainer 处理重复项

vim - 按箭头键时,取消 vim 终端模式

google-workflows - 如何在工作流中获取执行ID

c++ - FetchContent 与 ExternalProject

apache-kafka - 如何删除一个特定主题的组的消费者偏移量

google-apps-script - 无法获取部署 ID 错误的详细信息

python - 子进程无法使用 Pandas 执行文件

r - 作为二进制变量处理

javascript - 如何通过输入字段更改 slider ?

postgresql - 忽略 JetBrains 中的 extra_float_digits 参数