Пример #1
0
 public static bool CheckIfOmnisharpNeedsUpgrade()
 {
     if (Constants.OMNISHARP_VERSION == 0)
     {
         return(false);
     }
     #pragma warning disable
     var omnisharpVersionFile = PathManager.GetOmnisharpVersionFilePath();
     if (File.Exists(omnisharpVersionFile))
     {
         var version = File.ReadAllText(omnisharpVersionFile);
         Utility.Log(string.Format("Omnisharp Local Version: {0}", version));
         if (int.Parse(version) < Constants.OMNISHARP_VERSION)
         {
             return(true);
         }
         else
         {
             return(false);
         }
     }
     else
     {
         return(true);
     }
     #pragma warning restore
 }
Пример #2
0
        public static void UpdateOmnisharp()
        {
            try
            {
                Directory.Delete(GetInstallationFolder(), true);

                string zipFilePath = GetOmnisharpZipFile();

                // If the omnisharp zip file is missing,
                // don't do anythin and just return
                if (!File.Exists(zipFilePath))
                {
                    return;
                }

                string title   = "Upgrading Omnisharp";
                string message = "Omnisharp is upgrading...";

                string zipFileName = GetOminsharpZipFileName();

                string installationFolder = GetInstallationFolder();
                EditorUtility.DisplayProgressBar(title, message, 0f);

                // 1. copy zip file to installation folder
                string targetZipFilePath = Utility.PathCombine(installationFolder, zipFileName);
                EditorUtility.DisplayProgressBar(title, message, 0.3f);
                File.Copy(zipFilePath, targetZipFilePath, true);

                // 2. unzip it
                EditorUtility.DisplayProgressBar(title, message, 0.6f);
                UnZipFile(targetZipFilePath);

                // 3. delete zip file
                EditorUtility.DisplayProgressBar(title, message, 1f);
                Clean(targetZipFilePath);

                // 4. save omnisharp version
                File.WriteAllText(PathManager.GetOmnisharpVersionFilePath(), Constants.OMNISHARP_VERSION.ToString());
            }
            catch (Exception e)
            {
                UnityEngine.Debug.Log(e);
            }
            finally
            {
                EditorUtility.ClearProgressBar();
            }
        }