public static string ProcessBarFile()
		{
			try
			{
				// extract file
				string path = Path.GetDirectoryName(BarFileName);
				string extractPath = path + "/" + Path.GetFileNameWithoutExtension(BarFileName);
				if (Directory.Exists(extractPath)) Directory.Delete(extractPath, true);
				if (!Directory.Exists(extractPath)) Directory.CreateDirectory(extractPath);
				#if WIN32
				ZipFile.ExtractToDirectory(BarFileName, extractPath);
				#else
				using (var zip = Ionic.Zip.ZipFile.Read(BarFileName))
				{
					zip.ExtractAll(extractPath);
				}
				#endif
				
				// delete old meta data
				if (Directory.Exists(extractPath+"/META-INF")) Directory.Delete(extractPath+"/META-INF", true);

				// create directories
				if (!Directory.Exists(extractPath+"/native")) Directory.CreateDirectory(extractPath+"/native");

				// copy scoreloop files
				if (!string.IsNullOrEmpty(ScoreloopBundlePath))
				{
					path = extractPath + "/native/SLAwards.bundle";
					DirectoryCopy(ScoreloopBundlePath, path, true);
				}

				// update xml manifest
				if (UseClassicMode)
				{
					var serializer = new XmlSerializer(typeof(OldUnityXml.qnx), "http://www.BB10.com/schemas/application/1.0");
					OldUnityXml.qnx oldObj = null;
					using (var file = new FileStream(extractPath+"/native/bar-descriptor.xml", FileMode.Open, FileAccess.Read))
					{
						oldObj = (OldUnityXml.qnx)serializer.Deserialize(file);
					}

					if (oldObj != null)
					{
						serializer = new XmlSerializer(typeof(NewUnityXml.qnx), "http://www.qnx.com/schemas/application/1.0");
						var newObj = new NewUnityXml.qnx(oldObj);
						using (var file = new FileStream(extractPath+"/native/bar-descriptor.xml", FileMode.Create, FileAccess.Write))
						{
							serializer.Serialize(file, newObj);
						}
					}
					else
					{
						throw new Exception("Failed to Deserialize bar-descriptor.xml");
					}
				}
				else
				{
					var serializer = new XmlSerializer(typeof(NewUnityXml.qnx), "http://www.BB10.com/schemas/application/1.0");
					NewUnityXml.qnx oldObj = null;
					using (var file = new FileStream(extractPath+"/native/bar-descriptor.xml", FileMode.Open, FileAccess.Read))
					{
						oldObj = (NewUnityXml.qnx)serializer.Deserialize(file);
					}

					if (oldObj != null)
					{
						serializer = new XmlSerializer(typeof(NewUnityXml.qnx), "http://www.qnx.com/schemas/application/1.0");
						var newObj = new NewUnityXml.qnx(oldObj);
						using (var file = new FileStream(extractPath+"/native/bar-descriptor.xml", FileMode.Create, FileAccess.Write))
						{
							serializer.Serialize(file, newObj);
						}
					}
					else
					{
						throw new Exception("Failed to Deserialize bar-descriptor.xml");
					}
				}

				// repackage bar file >>>
				// <<< set java variables for windows
				#if WIN32
				Environment.SetEnvironmentVariable("JAVA_HOME", @"C:\Program Files (x86)\Java\jre7\bin");
				#endif

				// <<< create log file
				createLogFile();

				// get tool path
				string invokePath;
				if(UseClassicMode)
				{
					#if WIN32
					invokePath = UnityPath + @"\Editor\Data\PlaybackEngines\bb10player\blackberry-tools\bin";
					#else
					invokePath = UnityPath + "/Contents/PlaybackEngines/BB10Player/blackberry-tools/bin";
					#endif
				}
				else
				{
					#if WIN32
					invokePath = UnityPath + @"\Editor\Data\PlaybackEngines\blackberryplayer\blackberry-tools\bin";
					#else
					invokePath = UnityPath + "/Contents/PlaybackEngines/BlackBerryPlayer/Tools/blackberry-tools/bin";
					#endif
				}

				// <<< run packager
				string exe = "blackberry-nativepackager";
				#if WIN32
				exe += ".bat";
				#endif
				logWriter.WriteLine("Running " + exe);
				var info = new ProcessStartInfo(invokePath+"/"+exe, string.Format(@"{2}-package ""{0}"" ""{1}""", extractPath+"_Output.bar", extractPath+"/native/bar-descriptor.xml", !SignBarFile ? "-devMode " : ""));
				info.RedirectStandardOutput = true;
				info.RedirectStandardError = true;
				info.UseShellExecute = false;
				info.WorkingDirectory = extractPath+"/native";
				var process = new Process();
				process.StartInfo = info;
				process.OutputDataReceived += process_OutputDataReceived;
				process.ErrorDataReceived += process_ErrorDataReceived;
				if (!process.Start()) throw new Exception("Failed to start "+exe);
				process.BeginOutputReadLine();
				process.BeginErrorReadLine();
				process.WaitForExit();

				// <<< run signer
				if (SignBarFile)
				{
					exe = "blackberry-signer";
					#if WIN32
					exe += ".bat";
					#endif
					logWriter.WriteLine("Running " + exe);
					info = new ProcessStartInfo(invokePath+"/"+exe, string.Format(@"-storepass {0} ""{1}""", KeyPassword, extractPath+"_Output.bar"));
					info.RedirectStandardOutput = true;
					info.RedirectStandardError = true;
					info.UseShellExecute = false;
					process = new Process();
					process.StartInfo = info;
					process.OutputDataReceived += process_OutputDataReceived;
					process.ErrorDataReceived += process_ErrorDataReceived;
					if (!process.Start()) throw new Exception("Failed to start "+exe);
					process.BeginOutputReadLine();
					process.BeginErrorReadLine();
					process.WaitForExit();
				}
			}
			catch (Exception e)
			{
				if (logStream != null)
				{
					logWriter.Close();
					logStream.Close();
					logStream = null;
				}
				return e.Message;
			}
			
			if (logStream != null)
			{
				logWriter.Close();
				logStream.Close();
				logStream = null;
			}

			return null;
		}
        public static string ProcessBarFile()
        {
            try
            {
                // extract file
                string path        = Path.GetDirectoryName(BarFileName);
                string extractPath = path + "/" + Path.GetFileNameWithoutExtension(BarFileName);
                if (Directory.Exists(extractPath))
                {
                    Directory.Delete(extractPath, true);
                }
                if (!Directory.Exists(extractPath))
                {
                    Directory.CreateDirectory(extractPath);
                }
                                #if WIN32
                ZipFile.ExtractToDirectory(BarFileName, extractPath);
                                #else
                using (var zip = Ionic.Zip.ZipFile.Read(BarFileName))
                {
                    zip.ExtractAll(extractPath);
                }
                                #endif

                // delete old meta data
                if (Directory.Exists(extractPath + "/META-INF"))
                {
                    Directory.Delete(extractPath + "/META-INF", true);
                }

                // create directories
                if (!Directory.Exists(extractPath + "/native"))
                {
                    Directory.CreateDirectory(extractPath + "/native");
                }

                // copy scoreloop files
                if (!string.IsNullOrEmpty(ScoreloopBundlePath))
                {
                    path = extractPath + "/native/SLAwards.bundle";
                    DirectoryCopy(ScoreloopBundlePath, path, true);
                }

                // update xml manifest
                if (UseClassicMode)
                {
                    var             serializer = new XmlSerializer(typeof(OldUnityXml.qnx), "http://www.BB10.com/schemas/application/1.0");
                    OldUnityXml.qnx oldObj     = null;
                    using (var file = new FileStream(extractPath + "/native/bar-descriptor.xml", FileMode.Open, FileAccess.Read))
                    {
                        oldObj = (OldUnityXml.qnx)serializer.Deserialize(file);
                    }

                    if (oldObj != null)
                    {
                        serializer = new XmlSerializer(typeof(NewUnityXml.qnx), "http://www.qnx.com/schemas/application/1.0");
                        var newObj = new NewUnityXml.qnx(oldObj);
                        using (var file = new FileStream(extractPath + "/native/bar-descriptor.xml", FileMode.Create, FileAccess.Write))
                        {
                            serializer.Serialize(file, newObj);
                        }
                    }
                    else
                    {
                        throw new Exception("Failed to Deserialize bar-descriptor.xml");
                    }
                }
                else
                {
                    var             serializer = new XmlSerializer(typeof(NewUnityXml.qnx), "http://www.BB10.com/schemas/application/1.0");
                    NewUnityXml.qnx oldObj     = null;
                    using (var file = new FileStream(extractPath + "/native/bar-descriptor.xml", FileMode.Open, FileAccess.Read))
                    {
                        oldObj = (NewUnityXml.qnx)serializer.Deserialize(file);
                    }

                    if (oldObj != null)
                    {
                        serializer = new XmlSerializer(typeof(NewUnityXml.qnx), "http://www.qnx.com/schemas/application/1.0");
                        var newObj = new NewUnityXml.qnx(oldObj);
                        using (var file = new FileStream(extractPath + "/native/bar-descriptor.xml", FileMode.Create, FileAccess.Write))
                        {
                            serializer.Serialize(file, newObj);
                        }
                    }
                    else
                    {
                        throw new Exception("Failed to Deserialize bar-descriptor.xml");
                    }
                }

                // repackage bar file >>>
                // <<< set java variables for windows
                                #if WIN32
                Environment.SetEnvironmentVariable("JAVA_HOME", @"C:\Program Files (x86)\Java\jre7\bin");
                                #endif

                // <<< create log file
                createLogFile();

                // get tool path
                string invokePath;
                if (UseClassicMode)
                {
                                        #if WIN32
                    invokePath = UnityPath + @"\Editor\Data\PlaybackEngines\bb10player\blackberry-tools\bin";
                                        #else
                    invokePath = UnityPath + "/Contents/PlaybackEngines/BB10Player/blackberry-tools/bin";
                                        #endif
                }
                else
                {
                                        #if WIN32
                    invokePath = UnityPath + @"\Editor\Data\PlaybackEngines\blackberryplayer\blackberry-tools\bin";
                                        #else
                    invokePath = UnityPath + "/Contents/PlaybackEngines/BlackBerryPlayer/Tools/blackberry-tools/bin";
                                        #endif
                }

                // <<< run packager
                string exe = "blackberry-nativepackager";
                                #if WIN32
                exe += ".bat";
                                #endif
                logWriter.WriteLine("Running " + exe);
                var info = new ProcessStartInfo(invokePath + "/" + exe, string.Format(@"{2}-package ""{0}"" ""{1}""", extractPath + "_Output.bar", extractPath + "/native/bar-descriptor.xml", !SignBarFile ? "-devMode " : ""));
                info.RedirectStandardOutput = true;
                info.RedirectStandardError  = true;
                info.UseShellExecute        = false;
                info.WorkingDirectory       = extractPath + "/native";
                var process = new Process();
                process.StartInfo           = info;
                process.OutputDataReceived += process_OutputDataReceived;
                process.ErrorDataReceived  += process_ErrorDataReceived;
                if (!process.Start())
                {
                    throw new Exception("Failed to start " + exe);
                }
                process.BeginOutputReadLine();
                process.BeginErrorReadLine();
                process.WaitForExit();

                // <<< run signer
                if (SignBarFile)
                {
                    exe = "blackberry-signer";
                                        #if WIN32
                    exe += ".bat";
                                        #endif
                    logWriter.WriteLine("Running " + exe);
                    info = new ProcessStartInfo(invokePath + "/" + exe, string.Format(@"-storepass {0} ""{1}""", KeyPassword, extractPath + "_Output.bar"));
                    info.RedirectStandardOutput = true;
                    info.RedirectStandardError  = true;
                    info.UseShellExecute        = false;
                    process                     = new Process();
                    process.StartInfo           = info;
                    process.OutputDataReceived += process_OutputDataReceived;
                    process.ErrorDataReceived  += process_ErrorDataReceived;
                    if (!process.Start())
                    {
                        throw new Exception("Failed to start " + exe);
                    }
                    process.BeginOutputReadLine();
                    process.BeginErrorReadLine();
                    process.WaitForExit();
                }
            }
            catch (Exception e)
            {
                if (logStream != null)
                {
                    logWriter.Close();
                    logStream.Close();
                    logStream = null;
                }
                return(e.Message);
            }

            if (logStream != null)
            {
                logWriter.Close();
                logStream.Close();
                logStream = null;
            }

            return(null);
        }