private static void UpdateFilesInVCIfNeeded()
        {
            if (!Provider.enabled)
            {
                return;
            }

            var files = Directory.GetFiles(tempOutputPath, "*.*", SearchOption.AllDirectories);

            var assetList = new AssetList();

            foreach (string f in files)
            {
                assetList.Add(Provider.GetAssetByPath(f.Replace(tempOutputPath, "")));
            }

            var checkoutTask = Provider.Checkout(assetList, CheckoutMode.Exact);

            checkoutTask.Wait();

            var failedToCheckout = checkoutTask.assetList.Where(a => (a.state & Asset.States.ReadOnly) == Asset.States.ReadOnly);

            if (!checkoutTask.success || failedToCheckout.Any())
            {
                Debug.LogErrorFormat("[API Updater] Files cannot be updated (failed to check out): {0}", failedToCheckout.Select(a => a.fullName + " (" + a.state + ")").Aggregate((acc, curr) => acc + Environment.NewLine + "\t" + curr));
                ScriptUpdatingManager.ReportExpectedUpdateFailure();
                return;
            }

            FileUtil.CopyDirectoryRecursive(tempOutputPath, ".", true);
            FileUtil.DeleteFileOrDirectory(tempOutputPath);
        }
Example #2
0
        private static void UpdateFilesInVCIfNeeded()
        {
            if (!Provider.enabled)
            {
                return;
            }
            string[]  files  = Directory.GetFiles("Temp/ScriptUpdater/", "*.*", SearchOption.AllDirectories);
            AssetList assets = new AssetList();

            foreach (string str in files)
            {
                assets.Add(Provider.GetAssetByPath(str.Replace("Temp/ScriptUpdater/", string.Empty)));
            }
            Task task = Provider.Checkout(assets, CheckoutMode.Exact);

            task.Wait();
            IEnumerable <Asset> source = task.assetList.Where <Asset>((Func <Asset, bool>)(a => (a.state & Asset.States.ReadOnly) == Asset.States.ReadOnly));

            if (!task.success || source.Any <Asset>())
            {
                Debug.LogErrorFormat("[API Updater] Files cannot be updated (failed to check out): {0}", (object)source.Select <Asset, string>((Func <Asset, string>)(a => a.fullName + " (" + (object)a.state + ")")).Aggregate <string>((Func <string, string, string>)((acc, curr) => acc + Environment.NewLine + "\t" + curr)));
                ScriptUpdatingManager.ReportExpectedUpdateFailure();
            }
            else
            {
                FileUtil.CopyDirectoryRecursive("Temp/ScriptUpdater/", ".", true);
                FileUtil.DeleteFileOrDirectory("Temp/ScriptUpdater/");
            }
        }
Example #3
0
        private static void ReportAPIUpdaterFailure(IEnumerable <string> errorOutput)
        {
            Console.WriteLine("Failed to run script updater.\n ");
            IEnumerator <string> enumerator = errorOutput.GetEnumerator();

            try
            {
                while (enumerator.MoveNext())
                {
                    string current = enumerator.Current;
                    if (current.StartsWith("unity.console:"))
                    {
                        Debug.LogError(current.Substring("unity.console:".Length));
                    }
                    else
                    {
                        Console.WriteLine(current);
                    }
                }
            }
            finally
            {
                if (enumerator == null)
                {
                }
                enumerator.Dispose();
            }
            ScriptUpdatingManager.ReportExpectedUpdateFailure();
        }
Example #4
0
        public static void UpdateScripts(string responseFile, string sourceExtension)
        {
            if (!ScriptUpdatingManager.WaitForVCSServerConnection(true))
            {
                return;
            }
            string str = !Provider.enabled ? "." : "Temp/ScriptUpdater/";

            APIUpdaterHelper.RunUpdatingProgram("ScriptUpdater.exe", sourceExtension + " " + CommandLineFormatter.PrepareFileName(MonoInstallationFinder.GetFrameWorksFolder()) + " " + str + " " + responseFile);
        }
 private static void ReportAPIUpdaterFailure(IEnumerable <string> errorOutput)
 {
     Console.WriteLine("Failed to run script updater.\n ");
     foreach (string current in errorOutput)
     {
         if (current.StartsWith("unity.console:"))
         {
             Debug.LogError(current.Substring("unity.console:".Length));
         }
         else
         {
             Console.WriteLine(current);
         }
     }
     ScriptUpdatingManager.ReportExpectedUpdateFailure();
 }
Example #6
0
 private static void HandleUpdaterReturnValue(ManagedProgram program)
 {
     if (program.ExitCode == 0)
     {
         APIUpdaterHelper.UpdateFilesInVCIfNeeded();
         return;
     }
     ScriptUpdatingManager.ReportExpectedUpdateFailure();
     if (program.ExitCode > 0)
     {
         APIUpdaterHelper.ReportAPIUpdaterFailure(program.GetErrorOutput());
     }
     else
     {
         APIUpdaterHelper.ReportAPIUpdaterCrash(program.GetErrorOutput());
     }
 }
 public static void UpdateScripts(string responseFile, string sourceExtension)
 {
     if (ScriptUpdatingManager.WaitForVCSServerConnection(true))
     {
         string text = (!Provider.enabled) ? "." : "Temp/ScriptUpdater/";
         APIUpdaterHelper.RunUpdatingProgram("ScriptUpdater.exe", string.Concat(new string[]
         {
             sourceExtension,
             " ",
             CommandLineFormatter.PrepareFileName(MonoInstallationFinder.GetFrameWorksFolder()),
             " ",
             text,
             " ",
             responseFile
         }));
     }
 }
        private static void HandleUpdaterReturnValue(ManagedProgram program)
        {
            if (program.ExitCode == 0)
            {
                Console.WriteLine(string.Join(Environment.NewLine, program.GetErrorOutput()));
                UpdateFilesInVCIfNeeded();
                return;
            }

            ScriptUpdatingManager.ReportExpectedUpdateFailure();
            if (program.ExitCode > 0)
            {
                ReportAPIUpdaterFailure(program.GetErrorOutput());
            }
            else
            {
                ReportAPIUpdaterCrash(program.GetErrorOutput());
            }
        }
        public static void UpdateScripts(string responseFile, string sourceExtension)
        {
            if (!ScriptUpdatingManager.WaitForVCSServerConnection(true))
            {
                return;
            }

            var outputPath = Provider.enabled ? tempOutputPath : ".";

            RunUpdatingProgram(
                "ScriptUpdater.exe",
                sourceExtension
                + " "
                + CommandLineFormatter.PrepareFileName(MonoInstallationFinder.GetFrameWorksFolder())
                + " "
                + outputPath
                + " "
                + responseFile);
        }
        private static void UpdateFilesInVCIfNeeded()
        {
            if (!Provider.enabled)
            {
                return;
            }
            string[]  files     = Directory.GetFiles("Temp/ScriptUpdater/", "*.*", SearchOption.AllDirectories);
            AssetList assetList = new AssetList();

            string[] array = files;
            for (int i = 0; i < array.Length; i++)
            {
                string text = array[i];
                assetList.Add(Provider.GetAssetByPath(text.Replace("Temp/ScriptUpdater/", string.Empty)));
            }
            Task task = Provider.Checkout(assetList, CheckoutMode.Both);

            task.Wait();
            IEnumerable <Asset> source =
                from a in task.assetList
                where (a.state & Asset.States.ReadOnly) == Asset.States.ReadOnly
                select a;

            if (!task.success || source.Any <Asset>())
            {
                string   arg_103_0 = "[API Updater] Files cannot be updated (failed to checkout): {0}";
                object[] expr_BA   = new object[1];
                expr_BA[0] = (
                    from a in source
                    select string.Concat(new object[]
                {
                    a.fullName,
                    " (",
                    a.state,
                    ")"
                })).Aggregate((string acc, string curr) => acc + Environment.NewLine + "\t" + curr);
                Debug.LogErrorFormat(arg_103_0, expr_BA);
                ScriptUpdatingManager.ReportExpectedUpdateFailure();
                return;
            }
            FileUtil.CopyDirectoryRecursive("Temp/ScriptUpdater/", ".", true);
            FileUtil.DeleteFileOrDirectory("Temp/ScriptUpdater/");
        }
Example #11
0
        private static void ReportAPIUpdaterFailure(IEnumerable <string> errorOutput)
        {
            string msg = string.Format("APIUpdater encountered some issues and was not able to finish.{0}{1}", Environment.NewLine, errorOutput.Aggregate(string.Empty, (string acc, string curr) => acc + Environment.NewLine + "\t" + curr));

            ScriptUpdatingManager.ReportGroupedAPIUpdaterFailure(msg);
        }
        private static void UpdateFilesInVCIfNeeded()
        {
            if (!Provider.enabled)
            {
                return;
            }

            var files = Directory.GetFiles(tempOutputPath, "*.*", SearchOption.AllDirectories);

            var assetList = new AssetList();

            foreach (string f in files)
            {
                assetList.Add(Provider.GetAssetByPath(f.Replace(tempOutputPath, "")));
            }

            // Verify that all the files are also in assetList
            // This is required to ensure the copy temp files to destination loop is only working on version controlled files
            // Provider.GetAssetByPath() can fail i.e. the asset database GUID can not be found for the input asset path
            foreach (var f in files)
            {
                var rawAssetPath = f.Replace(tempOutputPath, "");
                // VCS assets path separator is '/' , file path might be '\' or '/'
                var assetPath  = (Path.DirectorySeparatorChar == '\\') ? rawAssetPath.Replace(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar) : rawAssetPath;
                var foundAsset = assetList.Where(asset => (asset.path == assetPath));
                if (!foundAsset.Any())
                {
                    Debug.LogErrorFormat("[API Updater] Files cannot be updated (failed to add file to list): {0}", rawAssetPath);
                    ScriptUpdatingManager.ReportExpectedUpdateFailure();
                    return;
                }
            }

            var checkoutTask = Provider.Checkout(assetList, CheckoutMode.Exact);

            checkoutTask.Wait();

            // Verify that all the files we need to operate on are now editable according to version control
            // One of these states:
            // 1) UnderVersionControl & CheckedOutLocal
            // 2) UnderVersionControl & AddedLocal
            // 3) !UnderVersionControl
            var notEditable = assetList.Where(asset => asset.IsUnderVersionControl && !asset.IsState(Asset.States.CheckedOutLocal) && !asset.IsState(Asset.States.AddedLocal));

            if (!checkoutTask.success || notEditable.Any())
            {
                Debug.LogErrorFormat("[API Updater] Files cannot be updated (failed to check out): {0}", notEditable.Select(a => a.fullName + " (" + a.state + ")").Aggregate((acc, curr) => acc + Environment.NewLine + "\t" + curr));
                ScriptUpdatingManager.ReportExpectedUpdateFailure();
                return;
            }

            // Verify that all the files we need to copy are now writable
            // Problems after API updating during ScriptCompilation if the files are not-writable
            notEditable = assetList.Where(asset => ((File.GetAttributes(asset.path) & FileAttributes.ReadOnly) == FileAttributes.ReadOnly));
            if (notEditable.Any())
            {
                Debug.LogErrorFormat("[API Updater] Files cannot be updated (files not writable): {0}", notEditable.Select(a => a.fullName).Aggregate((acc, curr) => acc + Environment.NewLine + "\t" + curr));
                ScriptUpdatingManager.ReportExpectedUpdateFailure();
                return;
            }

            // Copy the temp files to the destination : note this operates on "files"
            // Earlier have verified a one-to-one correspondence between assetList and "files"
            foreach (var sourceFileName in files)
            {
                var destFileName = sourceFileName.Replace(tempOutputPath, "");
                File.Copy(sourceFileName,  destFileName, true);
            }
            FileUtil.DeleteFileOrDirectory(tempOutputPath);
        }
Example #13
0
 private static void ReportAPIUpdaterFailure(IEnumerable <string> errorOutput)
 {
     ScriptUpdatingManager.ReportGroupedAPIUpdaterFailure(string.Format("APIUpdater encountered some issues and was not able to finish.{0}{1}", (object)Environment.NewLine, (object)errorOutput.Aggregate <string, string>(string.Empty, (Func <string, string, string>)((acc, curr) => acc + Environment.NewLine + "\t" + curr))));
 }