我的要求是在 PostProcessBuild 中执行一个 bash 脚本“PostProcessShellScript.sh”。Unity 构建运行良好,但在 Unity Cloud Build 中构建失败。
下面是我的代码:
public static void OnPostProcessBuild(BuildTarget target, string pathToBuiltProject) {
.....
string scriptPath = Application.dataPath + "/Plugins/Android/Editor/PostProcessShellScript.sh";
//Runs fine on Local Unity build
//RunInShell("C:\\Program Files\\bash.exe","/" + scriptPath + " " + " " + "/" + apkPath + "/"+ "/" + apkName, false);
RunInShell("open","/" + scriptPath + " " + " " + "/" + apkPath + "/"+ "/" + apkName, false);
}
public static void RunInShell(string file, string args, bool waitForExit = true) {
System.Diagnostics.Process ppScriptProcess = new System.Diagnostics.Process();
ppScriptProcess.StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Maximized;
ppScriptProcess.StartInfo.FileName = file;
ppScriptProcess.StartInfo.Arguments = args;
ppScriptProcess.StartInfo.UseShellExecute = false;
ppScriptProcess.StartInfo.CreateNoWindow = false;
ppScriptProcess.StartInfo.RedirectStandardOutput = true;
ppScriptProcess.StartInfo.RedirectStandardError = true;
ppScriptProcess.Start ()
}
UCB 上的错误详细信息:
!Unity 播放器导出失败!
!'default_-android' 的构建失败。编译失败
为目标“default_-android”发布 surbhijain87/roll-a-ball-game 的 build 22...
发布成功完成。
完毕。
构建步骤“执行 shell”将构建标记为失败
postbuildstatus 成功完成。完成:失败