Example #1
0
        public bool ExecuteTask()
        {
            //MessageDialogs md =  new MessageDialogs(MessageDialogs.DialogButtonType.Cancel, "Cancel Publish.", filename, Gtk.MessageType.Question);
            Tool.Logger.LogDebugInfo("Publish no sign", null);

            /*if (MainClass.Settings.ClearConsoleBeforRuning){
             *      Tool.Logger.LogDebugInfo("CLEAR CONSOLE");
             *      MainClass.MainWindow.OutputConsole.Clear();
             * }*/

            if (MainClass.Workspace.ActualProject == null)
            {
                SetError(MainClass.Languages.Translate("no_project_selected"));
                Tool.Logger.LogDebugInfo(MainClass.Languages.Translate("no_project_selected"), null);
                return(false);
            }

            project = MainClass.Workspace.ActualProject;
            Tool.Logger.LogDebugInfo(String.Format("Project -> {0}", MainClass.Workspace.ActualProject), null);

            ShowInfo("Publish project", MainClass.Workspace.ActualProject.ProjectName);

            if (String.IsNullOrEmpty(project.ProjectOutput))
            {
                if (!String.IsNullOrEmpty(MainClass.Workspace.OutputDirectory))
                {
                    project.ProjectOutput = MainClass.Workspace.OutputDirectory;
                }
                else
                {
                    project.ProjectOutput = project.AbsolutProjectDir;
                }
                Tool.Logger.LogDebugInfo(String.Format("Project Output-> {0}", project.ProjectOutput), null);
            }

            if (!Directory.Exists(project.OutputMaskToFullPath))
            {
                try{
                    Tool.Logger.LogDebugInfo(String.Format("CREATE DIR Output-> {0}", project.OutputMaskToFullPath), null);
                    Directory.CreateDirectory(project.OutputMaskToFullPath);
                }catch
                {
                    SetError(MainClass.Languages.Translate("cannot_create_output"));
                    return(false);
                }
            }

            List <string> filesList = new List <string>();

            //project.GetAllFiles(ref filesList);
            GetAllFiles(ref filesList, project.AbsolutProjectDir);

            string tempDir = MainClass.Paths.TempPublishDir;             //System.IO.Path.Combine(MainClass.Settings.PublishDirectory,"_temp");

            Tool.Logger.LogDebugInfo(String.Format("Temp Directory-> {0}", tempDir), null);

            if (!Directory.Exists(tempDir))
            {
                try{
                    Tool.Logger.LogDebugInfo(String.Format("CREATE Temp Directory-> {0}", tempDir), null);
                    Directory.CreateDirectory(tempDir);
                } catch {
                    SetError(MainClass.Languages.Translate("cannot_create_temp_f1", tempDir));
                    return(false);
                }
            }

            if ((listCombinePublish == null) || (listCombinePublish.Count < 1))
            {
                Tool.Logger.LogDebugInfo("Publish list empty", null);
                SetError(MainClass.Languages.Translate("publish_list_is_empty"));
                return(false);
                //project.GeneratePublishCombination();
            }

            bool isAndroid = false;

            foreach (CombinePublish ccc in  listCombinePublish)
            {
                CombineCondition crPlatform = ccc.combineRule.Find(x => x.ConditionId == MainClass.Settings.Platform.Id);
                if (crPlatform != null)
                {
                    if ((crPlatform.RuleId == (int)DeviceType.Android_1_6) ||
                        (crPlatform.RuleId == (int)DeviceType.Android_2_2))
                    {
                        isAndroid = true;
                        //Console.WriteLine("ANDROID FOUND");
                        CheckJava();
                    }
                }
            }

            if (!isJavaInstaled && isAndroid)
            {
                ShowError(MainClass.Languages.Translate("java_missing"), MainClass.Languages.Translate("java_missing_title"));

                /*MessageDialogsUrl md = new MessageDialogsUrl(MessageDialogsUrl.DialogButtonType.Ok,MainClass.Languages.Translate("java_missing"), MainClass.Languages.Translate("java_missing_title"),"http://moscrif.com/java-requirement", Gtk.MessageType.Error,ParentWindow);
                 * md.ShowDialog();*/
            }

            /*if (listCombinePublish.Count > 0) {
             *
             *      double step = 1 / (listCombinePublish.Count * 1.0);
             *      MainClass.MainWindow.ProgressStart(step, MainClass.Languages.Translate("publish"));
             *      progressDialog = new ProgressDialog(MainClass.Languages.Translate("publishing"),ProgressDialog.CancelButtonType.Cancel,listCombinePublish.Count,ParentWindow);//MainClass.MainWindow
             * }*/

            foreach (CombinePublish ccc in  listCombinePublish)            //listCC ){
            //if (!ccc.IsSelected) continue;
            //Console.WriteLine(ccc.ToString());

            {
                if (stopProcess)
                {
                    break;
                }

                if (String.IsNullOrEmpty(project.ProjectArtefac))
                {
                    project.ProjectArtefac = System.IO.Path.GetFileNameWithoutExtension(project.RelativeAppFilePath);
                }
                string fileName = project.ProjectArtefac;

                List <ConditionDevice> condList = new List <ConditionDevice>();


                foreach (CombineCondition cr in ccc.combineRule)
                {
                    ConditionDevice cd = new ConditionDevice(cr.ConditionName, cr.RuleName);
                    //condList.Add(new ConditionDevice(cr.ConditionName,cr.RuleName));
                    if (cr.ConditionId == MainClass.Settings.Resolution.Id)
                    {
                        Rule rl = MainClass.Settings.Resolution.Rules.Find(x => x.Id == cr.RuleId);
                        if (rl != null)
                        {
                            cd.Height = rl.Height;
                            cd.Width  = rl.Width;
                        }
                    }
                    condList.Add(cd);

                    fileName = fileName.Replace(String.Format("$({0})", cr.ConditionName), cr.RuleName);
                }

                parentTask         = new TaskMessage("Publishing", fileName, null);
                devicePublishError = false;

                ShowInfo("Publishing", fileName);

                /*if (progressDialog != null)
                 *       progressDialog.SetLabel (fileName );*/

                if (Directory.Exists(tempDir))
                {
                    try{
                        DirectoryInfo di = new DirectoryInfo(tempDir);
                        foreach (DirectoryInfo d in di.GetDirectories())
                        {
                            d.Delete(true);
                        }
                        foreach (FileInfo f in di.GetFiles())
                        {
                            f.Delete();
                        }
                    } catch {
                    }
                }

                CombineCondition crPlatform  = ccc.combineRule.Find(x => x.ConditionId == MainClass.Settings.Platform.Id);
                CombineCondition crRsolution = ccc.combineRule.Find(x => x.ConditionId == MainClass.Settings.Resolution.Id);

                if (crPlatform == null)
                {
                    SetError(MainClass.Languages.Translate("platform_not_found", MainClass.Settings.Platform.Name), parentTask);
                    continue;
                }

                Device dvc = project.DevicesSettings.Find(x => x.TargetPlatformId == crPlatform.RuleId);

                if (dvc == null)
                {
                    SetError(MainClass.Languages.Translate("device_not_found", crPlatform.ConditionName, crPlatform.RuleName), parentTask);
                    continue;
                }

                if (((crPlatform.RuleId == (int)DeviceType.Android_1_6) ||
                     (crPlatform.RuleId == (int)DeviceType.Android_2_2)) &&
                    (!isJavaInstaled))
                {
                    SetError(MainClass.Languages.Translate("java_missing"), parentTask);
                    ShowError(MainClass.Languages.Translate("java_missing"), fileName);
                    continue;
                }

                string dirPublish = MainClass.Tools.GetPublishDirectory(dvc.Platform.Specific);                //System.IO.Path.Combine(MainClass.Settings.PublishDirectory,dvc.Platform.Specific);//crPlatform.RuleName);

                if (!Directory.Exists(dirPublish))
                {
                    SetError(MainClass.Languages.Translate("publish_tool_not_found"), parentTask);
                    continue;
                }

                if (String.IsNullOrEmpty(dirPublish))
                {
                    SetError(MainClass.Languages.Translate("publish_tool_not_found_f1"), parentTask);
                    continue;
                }

                dvc.Application = project.AppFile.Name;                 // TTT

                if (String.IsNullOrEmpty(project.ProjectOutput))
                {
                    if (!String.IsNullOrEmpty(MainClass.Workspace.OutputDirectory))
                    {
                        project.ProjectOutput = MainClass.Workspace.OutputDirectory;
                    }
                    else
                    {
                        project.ProjectOutput = project.AbsolutProjectDir;
                    }
                }

                dvc.Output_Dir = project.OutputMaskToFullPath;

                dvc.Temp = tempDir;

                dvc.Temp       = LastSeparator(dvc.Temp);
                dvc.Publish    = LastSeparator(MainClass.Settings.PublishDirectory);
                dvc.Root       = LastSeparator(MainClass.Workspace.RootDirectory);
                dvc.Output_Dir = LastSeparator(dvc.Output_Dir);

                dvc.Conditions = condList.ToArray();

                List <int> mergeResolutions = new List <int>();
                string     resolution       = crRsolution.RuleName;
                mergeResolutions.Add(crRsolution.RuleId);

                // Ak je zaskrtnute Merge All Resolution
                // Najdem vsetky publishovatelne combinacie danej platformy (napr. vsetky publishovane andrroidy)
                // a vytiahnem z nich rezolution a spojim do string odeleneho &
                if (dvc.Includes.Skin != null)
                {
                    dvc.Includes.Skin.ResolutionJson = dvc.Includes.Skin.Resolution;
                    if (!String.IsNullOrEmpty(dvc.Includes.Skin.Name))
                    {
                        if (project.IncludeAllResolution)
                        {
                            resolution = "";
                            mergeResolutions.Clear();
                            foreach (CombinePublish cp in  listCombinePublish)
                            {
                                CombineCondition crPlatform2 = cp.combineRule.Find(x => x.ConditionId == MainClass.Settings.Platform.Id && x.RuleId == crPlatform.RuleId);
                                if (crPlatform2 != null)
                                {
                                    CombineCondition crResolution2 = cp.combineRule.Find(x => x.ConditionId == MainClass.Settings.Resolution.Id);
                                    if (crResolution2 != null)
                                    {
                                        resolution = resolution + crResolution2.RuleName + "&";
                                        mergeResolutions.Add(crResolution2.RuleId);
                                    }
                                }
                            }
                            resolution = resolution.Remove(resolution.Length - 1, 1);
                            ConditionDevice cd = condList.Find(x => x.Name == MainClass.Settings.Resolution.Name);
                            if (cd != null)
                            {
                                cd.Value       = resolution;
                                dvc.Conditions = condList.ToArray();
                            }
                        }
                    }
                }

                List <string> filesForPublish = new List <string>();

                foreach (string file in filesList)
                {
                    if (System.IO.Path.GetExtension(file) == ".msc")
                    {
                        continue;
                    }

                    string fileUpdate = FileUtility.AbsoluteToRelativePath(MainClass.Workspace.RootDirectory, file);

                    if (project.FilesProperty != null)
                    {
                        // vyhldam property suborov a pozriem ci nemam nejake conditiony nastavene
                        FileItem fi = project.FilesProperty.Find(x => x.SystemFilePath == fileUpdate);
                        if (fi != null)
                        {
                            if (fi.IsExcluded)
                            {
                                continue;
                            }

                            if (fi.ConditionValues == null)                             // nema ziadne konditions tak ho pridam
                            {
                                goto nav1;
                                //continue;
                            }
                            foreach (CombineCondition cr in ccc.combineRule)
                            {
                                ConditionRule conRile = fi.ConditionValues.Find(x => x.ConditionId == cr.ConditionId);
                                if (conRile != null)
                                {
                                    //if ((conRile.RuleId != cr.RuleId)) // subor ma condition daneho typu, ale nastavenu na inu hodnotu
                                    //goto nav;

                                    int resolutionId = -1;

                                    if (conRile.ConditionId == MainClass.Settings.Resolution.Id)
                                    {
                                        resolutionId = mergeResolutions.FindIndex(x => x == conRile.RuleId);
                                        //continue;
                                    }

                                    // mam merge resolution a subor patri do niektoreho mergnuteho resolution
                                    if ((conRile.ConditionId == MainClass.Settings.Resolution.Id) && (resolutionId > -1))
                                    {
                                        goto nav1;
                                    }

                                    // subor ma condition daneho typu, ale nastavenu na inu hodnotu
                                    if ((conRile.RuleId != cr.RuleId))
                                    {
                                        string msg1 = String.Format("File {0} REMOVE {1}-> {0}", fileUpdate, conRile.RuleId);
                                        Tool.Logger.LogDebugInfo(msg1, null);
                                        Console.WriteLine(msg1);
                                        goto nav;
                                    }
                                }
                            }
                        }
                    }
nav1:
                    fileUpdate = FileUtility.AbsoluteToRelativePath(project.AbsolutProjectDir, file);
                    fileUpdate = FileUtility.TrimStartingDotCharacter(fileUpdate);
                    fileUpdate = FileUtility.TrimStartingDirectorySeparator(fileUpdate);
                    filesForPublish.Add(fileUpdate);

                    /*string msg =String.Format("Add File to Publish-> {0}",fileUpdate);
                     * Tool.Logger.LogDebugInfo(msg,null);
                     * Console.WriteLine(msg);*/

                    nav :;
                }
                dvc.Includes.Files = filesForPublish.ToArray();

                List <string> fontForPublish = new List <string>();
                foreach (string fnt in dvc.Includes.Fonts)
                {
                    string tmp = fnt;
                    tmp = tmp.Replace('/', System.IO.Path.DirectorySeparatorChar);
                    tmp = tmp.Replace('\\', System.IO.Path.DirectorySeparatorChar);

                    fontForPublish.Add(tmp);
                }
                dvc.Includes.Fonts = fontForPublish.ToArray();

                dvc.Output_Name = fileName;

                dvc.PublishPropertisFull = new List <PublishProperty>();

                foreach (PublishProperty pp in dvc.PublishPropertisMask)
                {
                    PublishProperty ppFull = new PublishProperty(pp.PublishName);
                    ppFull.PublishValue = pp.PublishValue;
                    dvc.PublishPropertisFull.Add(ppFull);

                    if (pp.PublishName == Project.KEY_PERMISSION)
                    {
                        continue;
                    }
                    if (pp.PublishName == Project.KEY_CODESIGNINGIDENTITY)
                    {
                        continue;
                    }
                    if (pp.PublishName == Project.KEY_STOREPASSWORD)
                    {
                        continue;
                    }
                    if (pp.PublishName == Project.KEY_KEYPASSWORD)
                    {
                        continue;
                    }
                    if (pp.PublishName == Project.KEY_SUPPORTEDDEVICES)
                    {
                        continue;
                    }
                    if (pp.PublishName == Project.KEY_INSTALLOCATION)
                    {
                        continue;
                    }
                    if (pp.PublishName == Project.KEY_BUNDLEIDENTIFIER)
                    {
                        continue;
                    }
                    if (pp.PublishName == Project.KEY_ALIAS)
                    {
                        continue;
                    }
                    if (pp.PublishName == Project.KEY_APPLICATIONID)
                    {
                        continue;
                    }
                    if (pp.PublishName == Project.KEY_PASSWORD)
                    {
                        continue;
                    }

                    ppFull.PublishValue = project.ConvertProjectMaskPathToFull(pp.PublishValue);
                }

                //

                /*if(dvc.Includes.Skin != null){
                 *      dvc.Includes.Skin.ResolutionJson = dvc.Includes.Skin.Resolution;
                 *      if(!String.IsNullOrEmpty(dvc.Includes.Skin.Name)){
                 *              if(project.IncludeAllResolution){
                 *                      dvc.Includes.Skin.ResolutionJson = "*";
                 *              }
                 *      }
                 * }*/
                dvc.LogDebug        = MainClass.Settings.LogPublish;
                dvc.ApplicationType = project.ApplicationType;

                dvc.FacebookAppID = project.FacebookAppID;

                if (String.IsNullOrEmpty(project.FacebookAppID))
                {
                    dvc.FacebookAppID = "";
                }

                string path = System.IO.Path.Combine(dirPublish, "settings.mso");               //fileName+".mso"); //dvc.TargetPlatform + "_settings.mso");
                string json = dvc.GenerateJson();

                if (String.IsNullOrEmpty(json))
                {
                    SetError(MainClass.Languages.Translate("cannot_generate_mso"), parentTask);
                    continue;
                }

                try {
                    using (StreamWriter file = new StreamWriter(path)) {
                        file.Write(json);
                        file.Close();
                    }
                } catch {
                    SetError(MainClass.Languages.Translate("cannot_generate_mso"), parentTask);
                    continue;
                }

                //var platformRule = MainClass.Settings.Platform.Rules.Find(x => x.Id == dvc.TargetPlatformId);

                string appFile     = dvc.Platform.Specific + ".app"; /*dvc.TargetPlatform*/          //platformRule.Specific + ".app";
                string fullAppPath = System.IO.Path.Combine(MainClass.Settings.PublishDirectory, appFile);

                if (!System.IO.File.Exists(fullAppPath))
                {
                    SetError(MainClass.Languages.Translate("publish_tool_not_found_f2"), parentTask);
                    continue;
                }

                RunPublishTool(appFile, parentTask);

                /*if (RunPublishTool(appFile,parentTask) ){
                 *      parentTask.Message =MainClass.Languages.Translate("publish_successfully_done");
                 *      output.Add(parentTask);
                 *
                 *      //output.Add(new TaskMessage(MainClass.Languages.Translate("publish_successfully_done"),dvc.Platform.Specific,null));
                 * } else {
                 *      parentTask.Message =MainClass.Languages.Translate("publish_error");
                 *      Console.WriteLine(parentTask.Child.Message);
                 *      output.Add(parentTask);
                 *      //output.Add(new TaskMessage(MainClass.Languages.Translate("publish_error"),dvc.Platform.Specific,null));
                 * }*/
                if (MainClass.Platform.IsMac)
                {
                    ExitPublish(null, null);
                }

                if (devicePublishError)
                {
                    parentTask.Message = StateEnum.ERROR.ToString();
                    allPublishError    = true;
                    ShowError(StateEnum.ERROR.ToString(), " ");
                    //ShowError(lastMessage.Trim(),fileName);
                }
                else
                {
                    parentTask.Message = StateEnum.OK.ToString();
                    ShowInfo(" ", StateEnum.OK.ToString());
                }
                //parentTask.Message = //this.StateTask.ToString();
                //Console.WriteLine(parentTask.Child.Message);
                output.Add(parentTask);

                MainClass.MainWindow.ProgressStep();

                /*if (progressDialog != null)
                 *      cancelled = progressDialog.Update (fileName );*/
            }

            MainClass.MainWindow.ProgressEnd();

            /*if(progressDialog!= null){
             *      progressDialog.Destroy();
             * }*/
            //Console.WriteLine("allPublishError -> {0}",allPublishError);
            if (allPublishError)
            {
                this.stateTask = StateEnum.ERROR;
                string s = allErrors.ToString();

                if (s.Length > 120)
                {
                    s = s.Substring(0, 120);
                    s = s + " ... and more.";
                }

                ShowError(MainClass.Languages.Translate("publish_error"), " ");
                return(false);
            }
            if (stopProcess)
            {
                this.stateTask = StateEnum.CANCEL;
                ShowInfo(MainClass.Languages.Translate("Canceled"), " ", -1);

                return(false);
            }
            else
            {
                this.stateTask = StateEnum.OK;

                ShowInfo(" ", MainClass.Languages.Translate("publish_successfully_done"), 1);

                /*if(MainClass.Settings.OpenOutputAfterPublish){
                 *      if (!String.IsNullOrEmpty(project.ProjectOutput)){
                 *              MainClass.Tools.OpenFolder(project.OutputMaskToFullPath);
                 *      }
                 * }*/
                return(true);
            }
        }
Example #2
0
        public bool Export(string outputFile, bool Archive)
        {
            /*if (System.IO.File.Exists(outputFile)){
             *
             *      MessageDialogs md =
             *              new MessageDialogs(MessageDialogs.DialogButtonType.YesNo, MainClass.Languages.Translate("file_notcreate_is_exist") ,outputFile, Gtk.MessageType.Error);
             *       return false;
             * }*/


            string[]      filePaths = Directory.GetFiles(AbsolutProjectDir, "*", SearchOption.AllDirectories);
            List <string> fonts     = new List <string>();

            int lng = filePaths.Length;


            int    folderOffset = MainClass.Workspace.RootDirectory.Length;         //compressDir.Length + (compressDir.EndsWith("\\") ? 0 : 1);
            string signingOld   = String.Empty;
            Device device       = this.DevicesSettings.Find(x => x.Devicetype == DeviceType.iOS_5_0);

            if (device != null)
            {
                PublishProperty ppSigning = device.PublishPropertisMask.Find(x => x.PublishName == KEY_CODESIGNINGIDENTITY);
                if (ppSigning != null)
                {
                    signingOld             = ppSigning.PublishValue;
                    ppSigning.PublishValue = "";
                    try{
                        Save();
                    } catch (Exception ex) {
                        Tool.Logger.Error(ex.Message);
                    }
                }
            }

            if (Archive)
            {
                foreach (string lib in this.AppFile.Libs)
                {
                    string libPath = System.IO.Path.Combine(MainClass.Workspace.RootDirectory, lib);

                    if (Directory.Exists(libPath))
                    {
                        try{
                            filePaths = Directory.GetFiles(libPath, "*", SearchOption.AllDirectories);
                            lng       = lng + filePaths.Length;
                        }catch (Exception ex) {
                            Tool.Logger.Error(ex.Message);
                        }
                    }
                }


                filePaths = Directory.GetFiles(MainClass.Workspace.RootDirectory, "*.ttf", SearchOption.TopDirectoryOnly);

                if (MainClass.Platform.IsMac)                // for Mac UpperCase
                {
                    string[] filePaths2 = Directory.GetFiles(MainClass.Workspace.RootDirectory, "*.TTF", SearchOption.TopDirectoryOnly);

                    var list = new List <string>();
                    list.AddRange(filePaths);
                    list.AddRange(filePaths2);
                    filePaths = list.ToArray();
                }

                foreach (Device d in this.DevicesSettings)
                {
                    foreach (string font in d.Includes.Fonts)
                    {
                        string fontPath = System.IO.Path.Combine(MainClass.Workspace.RootDirectory, font);
                        if (System.IO.File.Exists(fontPath) && fonts.FindIndex(x => x == fontPath) < 0)
                        {
                            System.IO.FileInfo fi = new FileInfo(fontPath);
                            if (fi.DirectoryName == MainClass.Workspace.RootDirectory)                            // only font from workspace
                            {
                                fonts.Add(fontPath);
                            }
                        }
                    }
                }
                lng = lng + fonts.Count;
            }

            progressDialog = new ProgressDialog("Compressed...", ProgressDialog.CancelButtonType.None, lng + 2, MainClass.MainWindow);

            /*Timer timer = new Timer();
             * timer.Interval = 240;
             * timer.Elapsed += new ElapsedEventHandler(OnTimeElapsed);
             * timer.Start();*/


            FileStream      fsOut     = File.Create(outputFile);
            ZipOutputStream zipStream = new ZipOutputStream(fsOut);

            zipStream.SetLevel(4);

            string[] files = new string[] { this.AbsolutAppFilePath, this.FilePath };

            foreach (string file in files)
            {
                FileInfo fi = new FileInfo(file);

                string entryName = System.IO.Path.GetFileName(file);  //file.Substring(folderOffset);
                entryName = ZipEntry.CleanName(entryName);            // Removes drive from name and fixes slash direction
                ZipEntry newEntry = new ZipEntry(entryName);
                newEntry.DateTime = fi.LastWriteTime;                 // Note the zip format stores 2 second granularity

                // Specifying the AESKeySize triggers AES encryption. Allowable values are 0 (off), 128 or 256.
                //   newEntry.AESKeySize = 256;

                // To permit the zip to be unpacked by built-in extractor in WinXP and Server2003, WinZip 8, Java, and other older code,
                // you need to do one of the following: Specify UseZip64.Off, or set the Size.
                // If the file may be bigger than 4GB, or you do not need WinXP built-in compatibility, you do not need either,
                // but the zip will be in Zip64 format which not all utilities can understand.
                //   zipStream.UseZip64 = UseZip64.Off;
                newEntry.Size = fi.Length;

                zipStream.PutNextEntry(newEntry);

                // Zip the file in buffered chunks
                // the "using" will close the stream even if an exception occurs
                progressDialog.Update(entryName);
                byte[] buffer = new byte[4096];
                using (FileStream streamReader = File.OpenRead(file)) {
                    ICSharpCode.SharpZipLib.Core.StreamUtils.Copy(streamReader, zipStream, buffer);
                }
                zipStream.CloseEntry();
            }

            foreach (string file in fonts)
            {
                FileInfo fi = new FileInfo(file);

                string entryName = System.IO.Path.GetFileName(file);  //file.Substring(folderOffset);
                entryName = ZipEntry.CleanName(entryName);            // Removes drive from name and fixes slash direction
                ZipEntry newEntry = new ZipEntry(entryName);
                newEntry.DateTime = fi.LastWriteTime;                 // Note the zip format stores 2 second granularity

                // Specifying the AESKeySize triggers AES encryption. Allowable values are 0 (off), 128 or 256.
                //   newEntry.AESKeySize = 256;

                // To permit the zip to be unpacked by built-in extractor in WinXP and Server2003, WinZip 8, Java, and other older code,
                // you need to do one of the following: Specify UseZip64.Off, or set the Size.
                // If the file may be bigger than 4GB, or you do not need WinXP built-in compatibility, you do not need either,
                // but the zip will be in Zip64 format which not all utilities can understand.
                //   zipStream.UseZip64 = UseZip64.Off;
                newEntry.Size = fi.Length;

                zipStream.PutNextEntry(newEntry);

                // Zip the file in buffered chunks
                // the "using" will close the stream even if an exception occurs
                progressDialog.Update(entryName);
                byte[] buffer = new byte[4096];
                using (FileStream streamReader = File.OpenRead(file)) {
                    ICSharpCode.SharpZipLib.Core.StreamUtils.Copy(streamReader, zipStream, buffer);
                }
                zipStream.CloseEntry();
            }


            CompressFolder(this.AbsolutProjectDir, zipStream, folderOffset);

            if (Archive)
            {
                foreach (string lib in this.AppFile.Libs)
                {
                    string libPath = System.IO.Path.Combine(MainClass.Workspace.RootDirectory, lib);
                    if (System.IO.Directory.Exists(libPath))
                    {
                        CompressFolder(libPath, zipStream, folderOffset);
                    }
                }
            }

            if (!String.IsNullOrEmpty(signingOld))
            {
                device = this.DevicesSettings.Find(x => x.Devicetype == DeviceType.iOS_5_0);
                if (device != null)
                {
                    PublishProperty ppSigning = device.PublishPropertisMask.Find(x => x.PublishName == KEY_CODESIGNINGIDENTITY);
                    if (ppSigning != null)
                    {
                        ppSigning.PublishValue = signingOld;
                        try{
                            Save();
                        } catch (Exception ex) {
                            Tool.Logger.Error(ex.Message);
                        }
                    }
                }
            }

            zipStream.IsStreamOwner = true;
            zipStream.Close();
            progressDialog.Destroy();
            return(true);
        }