Exemplo n.º 1
0
        public override bool Execute()
        {
            if (StartDebug)
            {
                Debugger.Launch();
            }
            var asm = Preloader.LoadAssemblies(
                Preloader.GetPackageFolders(Preloader.RemoteInstall.None, Environment.CurrentDirectory, DefaultInstallationPaths.SystemRepositoryDirectory, "openwrap", "openfilesystem", "sharpziplib")
                );

            foreach (var assembly in asm.Select(x => x.Key))
            {
                Log.LogMessage(MessageImportance.Low, "Pre-loaded assembly " + assembly);
            }
            var openWrapAssembly = asm.Select(x => x.Key).First(x => x.GetName().Name.Equals("openwrap", StringComparison.OrdinalIgnoreCase));
            var initializer      = openWrapAssembly.GetType("OpenWrap.Build.BuildInitializer");
            var method           = initializer.GetMethod("Initialize", BindingFlags.Static | BindingFlags.Public);
            var values           = method.Invoke(null, new object[] { CurrentProjectFile, CurrentDirectory ?? Environment.CurrentDirectory }) as IDictionary <string, string>;

            Name           = values[BuildConstants.PACKAGE_NAME];
            Scope          = values[BuildConstants.PROJECT_SCOPE];
            DescriptorPath = values[BuildConstants.DESCRIPTOR_PATH];

            Log.LogMessage(MessageImportance.Normal, "OpenWrap correctly initialized.");
            foreach (var kv in values)
            {
                Log.LogMessage(MessageImportance.Normal, "{0}: {1}", kv.Key, kv.Value);
            }

            return(true);
        }
Exemplo n.º 2
0
 protected override void OnStartup(StartupEventArgs e)
 {
     Preloader.LoadAssemblies(
         Preloader.GetPackageFolders(Preloader.RemoteInstall.None, DefaultInstallationPaths.SystemRepositoryDirectory, "openfilesystem", "sharpziplib")
         );
     RegisterServices();
     ShowMainWindow();
     SendInitalDataPopulationMessage();
     base.OnStartup(e);
 }
Exemplo n.º 3
0
        static void Load(string vsVersion, string currentDirectory, IEnumerable <string> packagePaths)
        {
            var assemblies = Preloader.LoadAssemblies(packagePaths);
            Func <IDictionary <string, object>, int> runner = null;

            foreach (var asm in assemblies)
            {
                try
                {
                    var runnerType = (from type in asm.Key.GetExportedTypes()
                                      where type.Name.EndsWith("Runner")
                                      let mi = type.GetMethod("Main", BindingFlags.Public | BindingFlags.Static, null, new[] { typeof(IDictionary <string, object>) }, null)
                                               where mi != null
                                               select mi).FirstOrDefault();
                    if (runnerType != null)
                    {
                        runner = env => (int)runnerType.Invoke(null, new object[] { env });
                        break;
                    }
                }
                catch (Exception e)
                {
                    Debug.WriteLine(e);
                }
            }
            if (runner == null)
            {
                return;
            }
            var info = new Dictionary <string, object>(StringComparer.OrdinalIgnoreCase)
            {
                { "openwrap.cd", currentDirectory },
                { "openwrap.shell.commandline", "start-solutionplugin" },
                { "openwrap.shell.assemblies", assemblies.ToList() },
                { "openwrap.shell.version", "1.1" },
                { "openwrap.shell.type", "VisualStudio." + vsVersion },
                { "openwrap.scope", "build" },
                { "openwrap.shell.formatter", "OpenWrap.VisualStudio.OutputWindowCommandOutputFormatter, OpenWrap.VisualStudio.Shared" }
            };

            try
            {
                runner(info);
            }
            catch (Exception e)
            {
                Trace.Write("An error occured while running the runner, solution addin not loaded.\r\n" + e);
            }
        }