Ejemplo n.º 1
0
#pragma warning disable 28
        public static int Main(IDictionary <string, object> env)
        {
            bool requireFirstRunOnProjectUpgrade = false;
            bool inSystem        = true;
            var  serviceRegistry = new ServiceRegistry();

            serviceRegistry = serviceRegistry.Override <IEnvironment>(() =>
            {
                var cdenv = new CurrentDirectoryEnvironment(LocalFileSystem.Instance.GetDirectory(env.CurrentDirectory()))
                {
                    BeforeProjectRepositoryInitialized = (dir, options) =>
                    {
                        requireFirstRunOnProjectUpgrade = dir.GetFile("packages").Exists == false;
                        inSystem = false;
                    }
                };
                if (env.SysPath() != null)
                {
                    cdenv.SystemRepositoryDirectory = LocalFileSystem.Instance.GetDirectory(new Path(env.SysPath()).Combine("wraps"));
                }

                return(cdenv);
            });

            if (env.ShellArgs().ContainsNoCase("UseSystem"))
            {
                serviceRegistry
                .Override(() => new RuntimeAssemblyResolver
                {
                    IgnoreProjectAssemblies = true
                })
                .Override <ICommandRepository>(() => new CommandRepository(
                                                   ServiceLocator.GetService <IPackageManager>().CommandExports(
                                                       ServiceLocator.GetService <IEnvironment>(), true)
                                                   .SelectMany(x => x)
                                                   .Select(x => x.Descriptor)));
            }
            var formatterType = env.Formatter();

            if (formatterType != null)
            {
                serviceRegistry.Override(() => (ICommandOutputFormatter)Activator.CreateInstance(Type.GetType(formatterType)));
            }
            serviceRegistry.Initialize();

            //if (requireFirstRunOnProjectUpgrade)
            //{
            //    ServiceLocator.GetService<ICommandOutputFormatter>().Render(
            //        new Warning("This is the first time you run a version of OpenWrap that supports post-install hooks on this project. Please wait while we run the hooks for the current packages."));

            //    serviceRegistry.Initialize();
            //}

            return(new ConsoleCommandExecutor(ServiceLocator.GetService <IEnumerable <ICommandLocator> >(), ServiceLocator.GetService <IEventHub>(), ServiceLocator.GetService <ICommandOutputFormatter>())
                   .Execute(env.CommandLine(), env.ShellArgs()));
        }
Ejemplo n.º 2
0
#pragma warning disable 28
        public static int Main(IDictionary<string, object> env)
        {
            bool requireFirstRunOnProjectUpgrade = false;
            bool inSystem = true;
            var serviceRegistry = new ServiceRegistry();
            serviceRegistry = serviceRegistry.Override<IEnvironment>(() =>
            {
                var cdenv = new CurrentDirectoryEnvironment(LocalFileSystem.Instance.GetDirectory(env.CurrentDirectory()))
                {
                    BeforeProjectRepositoryInitialized = (dir, options) =>
                    {
                        requireFirstRunOnProjectUpgrade = dir.GetFile("packages").Exists == false;
                        inSystem = false;
                    }
                };
                if (env.SysPath() != null)
                    cdenv.SystemRepositoryDirectory = LocalFileSystem.Instance.GetDirectory(new Path(env.SysPath()).Combine("wraps"));

                return cdenv;
            });

            if (env.ShellArgs().ContainsNoCase("UseSystem"))
            {
                
                serviceRegistry
                    .Override(() => new RuntimeAssemblyResolver
                    {
                        IgnoreProjectAssemblies = true
                    })
                    .Override<ICommandRepository>(() => new CommandRepository(
                                                            ServiceLocator.GetService<IPackageManager>().CommandExports(
                                                                ServiceLocator.GetService<IEnvironment>(), true)
                                                                .SelectMany(x => x)
                                                                .Select(x => x.Descriptor)));
            }
            var formatterType = env.Formatter();
            if (formatterType != null)
            {
                serviceRegistry.Override(() => (ICommandOutputFormatter)Activator.CreateInstance(Type.GetType(formatterType)));
            }
            serviceRegistry.Initialize();

            //if (requireFirstRunOnProjectUpgrade)
            //{
            //    ServiceLocator.GetService<ICommandOutputFormatter>().Render(
            //        new Warning("This is the first time you run a version of OpenWrap that supports post-install hooks on this project. Please wait while we run the hooks for the current packages."));

            //    serviceRegistry.Initialize();
            //}

            return new ConsoleCommandExecutor(ServiceLocator.GetService<IEnumerable<ICommandLocator>>(), ServiceLocator.GetService<IEventHub>(), ServiceLocator.GetService<ICommandOutputFormatter>())
                .Execute(env.CommandLine(), env.ShellArgs());
        }
Ejemplo n.º 3
0
#pragma warning disable 28
        public static int Main(IDictionary<string, object> env)
        {
            bool requireFirstRunOnProjectUpgrade = false;

            var serviceRegistry = new ServiceRegistry();
            serviceRegistry = serviceRegistry.Override<IEnvironment>(() =>
            {
                var cdenv = new CurrentDirectoryEnvironment(LocalFileSystem.Instance.GetDirectory(env.CurrentDirectory()))
                {
                    BeforeProjectRepositoryInitialized = (dir, options) =>
                    {
                        requireFirstRunOnProjectUpgrade = dir.GetFile("packages").Exists == false;
                    }
                };
                var systemRepositoryPath = env.SystemRepositoryPath();
                var systemRootPath = env.SystemRootPath();
                if (systemRootPath != null)
                    cdenv.SystemRepositoryDirectory = LocalFileSystem.Instance.GetDirectory(new Path(systemRepositoryPath).Combine("wraps"));
                if (systemRepositoryPath != null)
                    cdenv.SystemRepositoryDirectory = LocalFileSystem.Instance.GetDirectory(new Path(systemRepositoryPath));

                return cdenv;
            });

            if (env.ShellArgs().ContainsNoCase("UseSystem"))
            {
                
                serviceRegistry
                    .Override(() => new RuntimeAssemblyResolver
                    {
                        IgnoreProjectAssemblies = true
                    })
                    .Override<ICommandRepository>(() => new CommandRepository(
                                                            ServiceLocator.GetService<IPackageManager>().CommandExports(
                                                                ServiceLocator.GetService<IEnvironment>(), true)
                                                                .SelectMany(x => x)
                                                                .Select(x => x.Descriptor)));
            }
            var formatterType = env.Formatter();
            if (formatterType != null)
            {
                serviceRegistry.Override(() => (ICommandOutputFormatter)Activator.CreateInstance(Type.GetType(formatterType)));
            }
            serviceRegistry.Initialize();

            return new ConsoleCommandExecutor(ServiceLocator.GetService<IEnumerable<ICommandLocator>>(), ServiceLocator.GetService<IEventHub>(), ServiceLocator.GetService<ICommandOutputFormatter>())
                .Execute(env.CommandLine(), env.ShellArgs());
        }
Ejemplo n.º 4
0
#pragma warning disable 28
        public static int Main(IDictionary <string, object> env)
        {
            bool requireFirstRunOnProjectUpgrade = false;

            var serviceRegistry = new ServiceRegistry();

            serviceRegistry = serviceRegistry.Override <IEnvironment>(() =>
            {
                var cdenv = new CurrentDirectoryEnvironment(LocalFileSystem.Instance.GetDirectory(env.CurrentDirectory()))
                {
                    BeforeProjectRepositoryInitialized = (dir, options) =>
                    {
                        requireFirstRunOnProjectUpgrade = dir.GetFile("packages").Exists == false;
                    }
                };
                if (env.SysPath() != null)
                {
                    cdenv.SystemRepositoryDirectory = LocalFileSystem.Instance.GetDirectory(new Path(env.SysPath()));
                }

                return(cdenv);
            });

            if (env.ShellArgs().ContainsNoCase("UseSystem"))
            {
                serviceRegistry
                .Override(() => new RuntimeAssemblyResolver
                {
                    IgnoreProjectAssemblies = true
                })
                .Override <ICommandRepository>(() => new CommandRepository(
                                                   ServiceLocator.GetService <IPackageManager>().CommandExports(
                                                       ServiceLocator.GetService <IEnvironment>(), true)
                                                   .SelectMany(x => x)
                                                   .Select(x => x.Descriptor)));
            }
            var formatterType = env.Formatter();

            if (formatterType != null)
            {
                serviceRegistry.Override(() => (ICommandOutputFormatter)Activator.CreateInstance(Type.GetType(formatterType)));
            }
            serviceRegistry.Initialize();

            return(new ConsoleCommandExecutor(ServiceLocator.GetService <IEnumerable <ICommandLocator> >(), ServiceLocator.GetService <IEventHub>(), ServiceLocator.GetService <ICommandOutputFormatter>())
                   .Execute(env.CommandLine(), env.ShellArgs()));
        }