Example #1
0
    public static void OnPostProcessBuild(BuildTarget target, string projectPath)
    {
        if (target != BuildTarget.iOS)
        {
            return;
        }

        Debug.Log("开始生成ipa!");
        // Debug.Log(projectPath);

        // // 覆盖旧文件
        var logFilePath = string.Format("{0}/{1}", XCodeToIpaFolderPath, LogFileName);
        // File.WriteAllText(logFilePath, null);

        var argList = ProcessHelper.CreateArgumentsContainer();

        argList.Add(string.Format("{0}/{1}", XCodeToIpaFolderPath, ShellFileName));
        argList.Add(logFilePath);
        argList.Add(projectPath);
        argList.Add(Path.GetFileName(projectPath));
        argList.Add(ProvisioningProfile);
        argList.Add(DefaultOptionsPlistPath);
        argList.Add(string.Format("> {0}", logFilePath));

        var process = ProcessHelper.Start(ProcessHelper.CreateStartInfo(null, ProcessHelper.CreateArguments(argList)));

        process.WaitForExit();

        //        Debug.Log(File.ReadAllText(logFilePath));
    }
Example #2
0
    private static void SignApk(string pathToBuildProject)
    {
        var unsignedApk   = GetUnSignedApkPath(pathToBuildProject);
        var signedApkPath = GetFinalApkPath(pathToBuildProject);

        FileHelper.DeleteFile(signedApkPath);

        var argList = ProcessHelper.CreateArgumentsContainer();

        argList.Add("jarsigner");
        argList.Add("-keystore PublishKey/nucleus.keystore");
        argList.Add("-storepass nucleus123");
        argList.Add("-sigalg MD5withRSA");
        argList.Add("-digestalg SHA1");
        argList.Add("-signedjar");
        argList.Add(signedApkPath);
        argList.Add(unsignedApk);
        argList.Add("nucleus");

        var p = ProcessHelper.Start(ProcessHelper.CreateStartInfo());

        ProcessHelper.WriteLine(p, ProcessHelper.CreateArguments(argList));
        ProcessHelper.WaitForExit(p);

        // 生成成功,这个也没什么用了
        FileHelper.DeleteFile(unsignedApk);
    }
Example #3
0
    public static void GenerateWinExe(BuildTarget target, string pathToBuiltProject, string channel)
    {
        if (target != BuildTarget.StandaloneWindows)
        {
            return;
        }

        var rootFolder     = Path.GetDirectoryName(pathToBuiltProject);
        var fileName       = Path.GetFileNameWithoutExtension(pathToBuiltProject);
        var configFilePath = string.Format("{0}/{1}/{2}_sfx.txt", SFXConfigFolder, channel, fileName);
        var buildAsExe     = File.Exists(configFilePath);
        var exePath        = Path.GetDirectoryName(rootFolder) + "/" + Path.GetFileName(rootFolder) + (buildAsExe ? ".exe" : ".rar");

        FileUtil.DeleteFileOrDirectory(exePath);

        var    argList    = ProcessHelper.CreateArgumentsContainer();
        var    regKeyPath = @"SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\WinRAR.exe";
        string winrarPath = null;

        try
        {
            var regKey = Registry.LocalMachine.OpenSubKey(regKeyPath);
            winrarPath = regKey.GetValue("").ToString();
            regKey.Close();
        }
        catch (Exception e)
        {
        }
        if (string.IsNullOrEmpty(winrarPath))
        {
            winrarPath = "WinRAR.exe";
        }
        argList.Add(string.Format("\"{0}\"", winrarPath));
        argList.Add("a");
        argList.Add("-r");
        argList.Add("-ep1");
        if (buildAsExe)
        {
            argList.Add("-sfx");
            argList.Add("-iicon" + string.Format("{0}/{1}/{2}.ico ", SFXConfigFolder, channel, fileName));
            argList.Add("-scuc");
            argList.Add("-z" + configFilePath);
        }
        argList.Add(exePath);
        argList.Add(rootFolder + "/*.*");

        var p = ProcessHelper.Start(ProcessHelper.CreateStartInfo());

        ProcessHelper.WriteLine(p, ProcessHelper.CreateArguments(argList));
        ProcessHelper.WaitForExit(p);
    }
Example #4
0
    private static void DecodeApk(string pathToBuildProject)
    {
        FileHelper.DeleteDirectory(GetDecodeApkFolder(pathToBuildProject), true);

        var argList = ProcessHelper.CreateArgumentsContainer();

        argList.Add("java -jar");
        argList.Add(ApkToolPath);
        argList.Add("d");
        argList.Add(pathToBuildProject);
        argList.Add("-o");
        argList.Add(GetDecodeApkFolder(pathToBuildProject));

        var p = ProcessHelper.Start(ProcessHelper.CreateStartInfo());

        ProcessHelper.WriteLine(p, ProcessHelper.CreateArguments(argList));
        ProcessHelper.WaitForExit(p);
    }
Example #5
0
    private static void EncodeApk(string pathToBuildProject)
    {
        var unsignedApk = GetUnSignedApkPath(pathToBuildProject);

        FileHelper.DeleteFile(unsignedApk);

        var argList = ProcessHelper.CreateArgumentsContainer();

        argList.Add("java -jar");
        argList.Add(ApkToolPath);
        argList.Add("b");
        argList.Add(GetDecodeApkFolder(pathToBuildProject));
        argList.Add("-o");
        argList.Add(unsignedApk);
        var cmd = string.Join(" ", argList.ToArray());

        var p = ProcessHelper.Start(ProcessHelper.CreateStartInfo());

        ProcessHelper.WriteLine(p, ProcessHelper.CreateArguments(argList));
        ProcessHelper.WaitForExit(p);
    }
Example #6
0
    /// <summary>
    /// 得配置ZipAlign路径
    /// </summary>
    /// <param name="pathToBuildProject"></param>
    private static void ZipAlignmentApk(string pathToBuildProject)
    {
        var signedApkPath = GetSignedApkPath(pathToBuildProject);
        var finalApkPath  = GetFinalApkPath(pathToBuildProject);

        FileHelper.DeleteFile(finalApkPath);

        var argList = ProcessHelper.CreateArgumentsContainer();

        argList.Add("zipalign");
        argList.Add("-v 4");
        argList.Add(signedApkPath);
        argList.Add(finalApkPath);

        var p = ProcessHelper.Start(ProcessHelper.CreateStartInfo());

        ProcessHelper.WriteLine(p, ProcessHelper.CreateArguments(argList));
        ProcessHelper.WaitForExit(p);

        // 生成成功,这个也没什么用了
        FileHelper.DeleteFile(signedApkPath);
    }