예제 #1
0
        public bool TryFinalizeInstall(Install install)
        {
            Logger.Log("Finalizing " + install.ToShortString());

            if (!File.Exists(install.GetInstallerPath()))
            {
                Logger.Log("No installer found for " + install.ToShortString() + " - This is normal.");
                Logger.Log("Considering " + install.ToShortString() + " installed.");
                return(true); //Nothing to install
            }

            Logger.Log("Found installer at " + install.GetInstallerPath());
            Logger.Log("Compiling now...");

            var installerCode = File.ReadAllText(install.GetInstallerPath());

            CSharpCodeProvider provider   = new CSharpCodeProvider();
            CompilerParameters parameters = new CompilerParameters();

            // True - memory generation, false - external file generation
            parameters.GenerateInMemory = true;
            // True - exe file generation, false - dll file generation
            parameters.GenerateExecutable = false;

            var assemblies = AppDomain.CurrentDomain.GetAssemblies().ToArray();

            foreach (var assembly in assemblies)
            {
                parameters.ReferencedAssemblies.Add(assembly.Location);
            }

            CompilerResults results = provider.CompileAssemblyFromSource(parameters, installerCode);

            if (results.Errors.HasErrors)
            {
                StringBuilder sb = new StringBuilder();

                foreach (CompilerError error in results.Errors)
                {
                    sb.AppendLine(String.Format("Error ({0}): {1}", error.ErrorNumber, error.ErrorText));
                }



                throw new InvalidOperationException(sb.ToString());
            }

            Logger.Log("Compiled! Executing...");

            Assembly resultAssembly = results.CompiledAssembly;
            Type     program        = resultAssembly.GetTypes().FirstOrDefault(t => typeof(Installer).IsAssignableFrom(t));

            var installer = (Installer)Activator.CreateInstance(program, new object[] { CliFrontend });

            MethodInfo main = program.GetMethod("PostInstall");

            return((bool)main.Invoke(installer, new object[] { install }));
        }
예제 #2
0
        public void UninstallNode(Install selectedPackage)
        {
            var installation = new Uninstallation(this, this, GithubApi, Logger);
            var result       = installation.Uninstall(selectedPackage);

            if (selectedPackage.ConfigData.RequiresFullReimport)
            {
                var msg = "Deinstalled package requires full reimport " + selectedPackage.ToShortString();

                ThreadingUtils.DispatchOnMainThread(() =>
                {
                    if (EditorUtility.DisplayDialog("Koinonia", msg, "Ok", "No, I'll do it myself"))
                    {
                        EditorApplication.ExecuteMenuItem("Assets/Reimport All");
                    }
                    else
                    {
                        AssetDatabase.Refresh();
                    }
                });
            }
            else
            {
                ThreadingUtils.DispatchOnMainThread(AssetDatabase.Refresh);
            }
        }
예제 #3
0
        private void Add(Install toUninstall)
        {
            _logger.Log("Adding " + toUninstall.ToShortString() + " to the deinstall queue");

            UninstallPlan.Add(toUninstall);
        }