在Unity Cloud Build中执行bash脚本

时间:2017-02-27 09:24:25

标签: c# android bash unity3d unity3d-cloud-build

我的要求是执行bash脚本" PostProcessShellScript.sh"在PostProcessBuild中。 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'失败。编译失败

     

为目标发布surbhijain87 / roll-a-ball-game的build 22   ' default_-android' ...

     

发布成功完成。

     

完成。

     

构建步骤'执行shell'将构建标记为失败

     

postbuildstatus成功完成。完成:失败

1 个答案:

答案 0 :(得分:0)

太隐含了。

我正在使用 shell脚本来解决问题。

在mono和shell脚本上运行的UCB看起来很可行。

您的分辨率:将代码转换为Shell脚本并从用户界面附加到UCB配置上