private static IEnvironment GetEnvironment() { var environment = new CurrentDirectoryEnvironment(); environment.Initialize(); return(environment); }
#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())); }
#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())); }
public static int Main(IDictionary <string, object> env) { Services.ServiceLocator.TryRegisterService <IFileSystem>(() => LocalFileSystem.Instance); Services.ServiceLocator.TryRegisterService <IConfigurationManager>( () => new DefaultConfigurationManager(Services.ServiceLocator.GetService <IFileSystem>().GetDirectory(DefaultInstallationPaths.ConfigurationDirectory))); Services.ServiceLocator.TryRegisterService <IEnvironment>(() => { var cdenv = new CurrentDirectoryEnvironment(LocalFileSystem.Instance.GetDirectory(env.CurrentDirectory())); if (env.SysPath() != null) { cdenv.SystemRepositoryDirectory = LocalFileSystem.Instance.GetDirectory(env.SysPath()); } return(cdenv); }); Services.ServiceLocator.TryRegisterService <IPackageResolver>(() => new ExhaustiveResolver()); Services.ServiceLocator.TryRegisterService <IPackageExporter>(() => new DefaultPackageExporter(new List <IExportProvider>() { new DefaultAssemblyExporter(), new CecilCommandExporter() })); Services.ServiceLocator.TryRegisterService <IPackageDeployer>(() => new DefaultPackageDeployer()); Services.ServiceLocator.TryRegisterService <IPackageManager>(() => new DefaultPackageManager( Services.ServiceLocator.GetService <IPackageDeployer>(), Services.ServiceLocator.GetService <IPackageResolver>(), Services.ServiceLocator.GetService <IPackageExporter>() )); Services.ServiceLocator.RegisterService <ITaskManager>(new TaskManager()); ServiceLocator.TryRegisterService <IAssemblyResolver>(() => new CecilStaticAssemblyResolver(ServiceLocator.GetService <IPackageManager>(), ServiceLocator.GetService <IEnvironment>())); var commands = Services.ServiceLocator.GetService <IPackageManager>().CommandExports(ServiceLocator.GetService <IEnvironment>()); var commandRepository = new CommandRepository(commands.SelectMany(x => x).Select(x => x.Descriptor)); Services.ServiceLocator.TryRegisterService <ICommandRepository>(() => commandRepository); Services.ServiceLocator.RegisterService(new RuntimeAssemblyResolver()); return(new ConsoleCommandExecutor(ServiceLocator.GetService <ICommandRepository>(), new List <ICommandLocator> { new NounVerbCommandLocator(commandRepository), new VerbNounCommandLocator(commandRepository), new DefaultVerbCommandLocator(commandRepository) }).Execute(env.CommandLine(), env.ShellArgs())); }
IEnumerable <ICommandOutput> SetEnvironmentToFromInput() { if (From != null) { var directory = _fileSystem.GetDirectory(From); if (directory.Exists == false) { yield return(new DirectoryNotFound(directory)); yield break; } var newEnv = new CurrentDirectoryEnvironment(directory); newEnv.Initialize(); _environment = newEnv; } }
IEnumerable <ICommandOutput> FromEnvironmentNotFound() { if (From != null) { var directory = _fileSystem.GetDirectory(From); if (directory.Exists == false) { yield return(new Error("Directory '{0}' not found.", From)); yield break; } var newEnv = new CurrentDirectoryEnvironment(directory); newEnv.Initialize(); if (newEnv.ScopedDescriptors.Any() == false) { yield return(new Error("No descriptor found in directory '{0}'.", From)); yield break; } _environment = newEnv; //return new Info("Building package at '{0}'.", From); } }