From 8a1c9cc46f7d219b86056af2439a336c57c87725 Mon Sep 17 00:00:00 2001 From: Renaud Paquay Date: Wed, 28 Apr 2010 18:21:32 -0700 Subject: [PATCH] Make "setup" command available for "orchard.exe" Extracted the setup code into a "SetupService" used by setup controller and command. --HG-- branch : dev --- .../Commands/TenantCommand.cs | 1 + .../Orchard.Setup/Commands/SetupCommand.cs | 62 ++++++++ .../Controllers/SetupController.cs | 146 ++++-------------- .../Orchard.Setup/Orchard.Setup.csproj | 4 + .../Orchard.Setup/Services/ISetupService.cs | 5 + .../Orchard.Setup/Services/SetupContext.cs | 13 ++ .../Orchard.Setup/Services/SetupService.cs | 140 +++++++++++++++++ .../Modules/Orchard.Setup/SetupMode.cs | 6 + .../ViewModels/SetupViewModel.cs | 6 +- src/Orchard/Commands/CommandHostAgent.cs | 22 ++- src/Tools/Orchard/OrchardHost.cs | 3 - 11 files changed, 286 insertions(+), 122 deletions(-) create mode 100644 src/Orchard.Web/Modules/Orchard.Setup/Commands/SetupCommand.cs create mode 100644 src/Orchard.Web/Modules/Orchard.Setup/Services/ISetupService.cs create mode 100644 src/Orchard.Web/Modules/Orchard.Setup/Services/SetupContext.cs create mode 100644 src/Orchard.Web/Modules/Orchard.Setup/Services/SetupService.cs diff --git a/src/Orchard.Web/Modules/Orchard.MultiTenancy/Commands/TenantCommand.cs b/src/Orchard.Web/Modules/Orchard.MultiTenancy/Commands/TenantCommand.cs index 76b59ea1e..044d363bc 100644 --- a/src/Orchard.Web/Modules/Orchard.MultiTenancy/Commands/TenantCommand.cs +++ b/src/Orchard.Web/Modules/Orchard.MultiTenancy/Commands/TenantCommand.cs @@ -39,6 +39,7 @@ namespace Orchard.MultiTenancy.Commands { [CommandHelp("tenant add /Host: /UrlPrefix:\r\n\t" + "Create new tenant named on the site")] [CommandName("tenant add")] + [OrchardSwitches("Host,UrlPrefix")] public void Create(string tenantName) { Context.Output.WriteLine(T("Creating tenant")); _tenantService.CreateTenant( diff --git a/src/Orchard.Web/Modules/Orchard.Setup/Commands/SetupCommand.cs b/src/Orchard.Web/Modules/Orchard.Setup/Commands/SetupCommand.cs new file mode 100644 index 000000000..69943779f --- /dev/null +++ b/src/Orchard.Web/Modules/Orchard.Setup/Commands/SetupCommand.cs @@ -0,0 +1,62 @@ +using System.Linq; +using Orchard.Commands; +using Orchard.Setup.Services; + +namespace Orchard.Setup.Commands { + public class SetupCommand : DefaultOrchardCommandHandler { + private readonly ISetupService _setupService; + + public SetupCommand(ISetupService setupService) { + _setupService = setupService; + } + + [OrchardSwitch] + public string SiteName { get; set; } + + [OrchardSwitch] + public string AdminUsername { get; set; } + + [OrchardSwitch] + public string AdminPassword { get; set; } + + [OrchardSwitch] + public string DatabaseProvider { get; set; } + + [OrchardSwitch] + public string DatabaseConnectionString { get; set; } + + [OrchardSwitch] + public string DatabaseTablePrefix { get; set; } + + [OrchardSwitch] + public string EnabledFeatures { get; set; } + + [CommandHelp("setup /SiteName: /AdminUserName: /AdminPassword: /DatabaseProvider: " + + "/DatabaseConnectionString: /DatabaseTablePrefix: /EnabledFeatures:" + + "\r\n\tRun first time setup for the site or for a given tenant")] + [CommandName("setup")] + [OrchardSwitches("SiteName,AdminUsername,AdminPassword,DatabaseProvider,DatabaseConnectionString,DatabaseTablePrefix,EnabledFeatures")] + public void Setup() { + var setupContext = new SetupContext { + SiteName = this.SiteName, + AdminUsername = this.AdminUsername, + AdminPassword = this.AdminPassword, + DatabaseProvider = this.DatabaseProvider, + DatabaseConnectionString = this.DatabaseConnectionString, + DatabaseTablePrefix = this.DatabaseTablePrefix, + EnabledFeatures = this.EnabledFeatures.Split(',').Select(s => s.Trim()) + }; + + _setupService.Setup(setupContext); + + Context.Output.WriteLine("Site \"{0}\" setup to run data provider \"{1}\" (with table prefix \"{2}\") with the following features enabled:", + setupContext.SiteName, + setupContext.DatabaseProvider, + setupContext.DatabaseTablePrefix); + + foreach (var feature in setupContext.EnabledFeatures) { + this.Context.Output.WriteLine("{0}", feature); + } + } + } +} diff --git a/src/Orchard.Web/Modules/Orchard.Setup/Controllers/SetupController.cs b/src/Orchard.Web/Modules/Orchard.Setup/Controllers/SetupController.cs index 2ded69bb3..ec5667457 100644 --- a/src/Orchard.Web/Modules/Orchard.Setup/Controllers/SetupController.cs +++ b/src/Orchard.Web/Modules/Orchard.Setup/Controllers/SetupController.cs @@ -15,6 +15,7 @@ using Orchard.Environment.Topology; using Orchard.Environment.Topology.Models; using Orchard.Security; using Orchard.Settings; +using Orchard.Setup.Services; using Orchard.Setup.ViewModels; using Orchard.Localization; using Orchard.Themes; @@ -23,29 +24,14 @@ using Orchard.UI.Notify; namespace Orchard.Setup.Controllers { [ValidateInput(false)] public class SetupController : Controller { - private readonly ShellSettings _shellSettings; - private readonly INotifier _notifier; - private readonly IOrchardHost _orchardHost; - private readonly IShellSettingsManager _shellSettingsManager; - private readonly IShellContainerFactory _shellContainerFactory; - private readonly ICompositionStrategy _compositionStrategy; private readonly IAppDataFolder _appDataFolder; + private readonly INotifier _notifier; + private readonly ISetupService _setupService; - public SetupController( - ShellSettings shellSettings, - INotifier notifier, - IOrchardHost orchardHost, - IShellSettingsManager shellSettingsManager, - IShellContainerFactory shellContainerFactory, - ICompositionStrategy compositionStrategy, - IAppDataFolder appDataFolder) { - _shellSettings = shellSettings; - _notifier = notifier; - _orchardHost = orchardHost; - _shellSettingsManager = shellSettingsManager; - _shellContainerFactory = shellContainerFactory; - _compositionStrategy = compositionStrategy; + public SetupController(INotifier notifier, ISetupService setupService, IAppDataFolder appDataFolder) { _appDataFolder = appDataFolder; + _notifier = notifier; + _setupService = setupService; T = NullLocalizer.Instance; } @@ -78,103 +64,37 @@ namespace Orchard.Setup.Controllers { } try { - var shellSettings = new ShellSettings(_shellSettings) { - DataProvider = model.DatabaseOptions ? "SQLite" : "SqlServer", - DataConnectionString = model.DatabaseConnectionString, - DataTablePrefix = model.DatabaseTablePrefix, - }; - // The vanilla Orchard distibution has the following features enabled. - const string hardcoded = - @"Orchard.Framework, - Common,Dashboard,Feeds,HomePage,Navigation,Scheduling,Settings,XmlRpc, - Orchard.Users,Orchard.Roles,TinyMce, - Orchard.Modules,Orchard.Themes, - Orchard.Pages,Orchard.Comments"; + string[] hardcoded = { + "Orchard.Framework", + "Common", + "Dashboard", + "Feeds", + "HomePage", + "Navigation", + "Scheduling", + "Settings", + "XmlRpc", + "Orchard.Users", + "Orchard.Roles", + "TinyMce", + "Orchard.Modules", + "Orchard.Themes", + "Orchard.MultiTenancy", + "Orchard.Pages", + "Orchard.Comments" }; - var shellDescriptor = new ShellDescriptor { - EnabledFeatures = hardcoded.Split(',').Select(name => new ShellFeature { Name = name.Trim() }) + var setupContext = new SetupContext { + SiteName = model.SiteName, + AdminUsername = model.AdminUsername, + AdminPassword = model.AdminPassword, + DatabaseProvider = model.DatabaseOptions ? "SQLite" : "SqlServer", + DatabaseConnectionString = model.DatabaseConnectionString, + DatabaseTablePrefix = model.DatabaseTablePrefix, + EnabledFeatures = hardcoded }; - var shellToplogy = _compositionStrategy.Compose(shellSettings, shellDescriptor); - - // initialize database explicitly, and store shell descriptor - var bootstrapLifetimeScope = _shellContainerFactory.CreateContainer(shellSettings, shellToplogy); - using (var environment = new StandaloneEnvironment(bootstrapLifetimeScope)) { - environment.Resolve().CreateDatabase(); - - environment.Resolve().UpdateShellDescriptor( - 0, - shellDescriptor.EnabledFeatures, - shellDescriptor.Parameters); - } - - - // creating a standalone environment. - // in theory this environment can be used to resolve any normal components by interface, and those - // components will exist entirely in isolation - no crossover between the safemode container currently in effect - - // must mark state as Running - otherwise standalone enviro is created "for setup" - shellSettings.State = new TenantState("Running"); - using (var environment = _orchardHost.CreateStandaloneEnvironment(shellSettings)) { - try { - // create superuser - var membershipService = environment.Resolve(); - var user = - membershipService.CreateUser(new CreateUserParams(model.AdminUsername, model.AdminPassword, - String.Empty, String.Empty, String.Empty, - true)); - - - // set site name and settings - var siteService = environment.Resolve(); - var siteSettings = siteService.GetSiteSettings().As(); - siteSettings.Record.SiteSalt = Guid.NewGuid().ToString("N"); - siteSettings.Record.SiteName = model.SiteName; - siteSettings.Record.SuperUser = model.AdminUsername; - siteSettings.Record.PageTitleSeparator = " - "; - - // set site theme - var themeService = environment.Resolve(); - themeService.SetSiteTheme("Classic"); - - var contentManager = environment.Resolve(); - - // simulate installation-time module activation events - var hackInstallationGenerator = environment.Resolve(); - hackInstallationGenerator.GenerateInstallEvents(); - - // create home page as a CMS page - var page = contentManager.Create("page", VersionOptions.Draft); - page.As().Text = "

Welcome to Orchard!

Congratulations, you've successfully set-up your Orchard site.

This is the home page of your new site. We've taken the liberty to write here about a few things you could look at next in order to get familiar with the application. Once you feel confident you don't need this anymore, just click Edit to go into edit mode and replace this with whatever you want on your home page to make it your own.

One thing you could do (but you don't have to) is go into Manage Settings (follow the Admin link and then look for it under \"Settings\" in the menu on the left) and check that everything is configured the way you want.

You probably want to make the site your own. One of the ways you can do that is by clicking Manage Themes in the admin menu. A theme is a packaged look and feel that affects the whole site.

Next, you can start playing with the content types that we installed. For example, go ahead and click Add New Page in the admin menu and create an \"about\" page. Then, add it to the navigation menu by going to Manage Menu. You can also click Add New Blog and start posting by clicking \"Add New Post\".

Finally, Orchard has been designed to be extended. It comes with a few built-in modules such as pages and blogs or themes. You can install new themes by going to Manage Themes and clicking Install a new Theme. Like for themes, modules are created by other users of Orchard just like you so if you feel up to it, please consider participating.

--The Orchard Crew

"; - page.As().Slug = "home"; - page.As().Title = T("Home").ToString(); - page.As().CommentsShown = false; - page.As().Owner = user; - contentManager.Publish(page); - siteSettings.Record.HomePage = "PageHomePageProvider;" + page.Id; - - // add a menu item for the shiny new home page - var menuItem = contentManager.Create("menuitem"); - menuItem.As().MenuPosition = "1"; - menuItem.As().MenuText = T("Home").ToString(); - menuItem.As().OnMainMenu = true; - menuItem.As().Url = ""; - - var authenticationService = environment.Resolve(); - authenticationService.SignIn(user, true); - - } - catch { - environment.Resolve().Cancel(); - throw; - } - } - - _shellSettingsManager.SaveSettings(shellSettings); - - // MultiTenancy: This will not be needed when host listens to event bus - _orchardHost.Reinitialize_Obsolete(); + _setupService.Setup(setupContext); // redirect to the welcome page. return Redirect("~/"); diff --git a/src/Orchard.Web/Modules/Orchard.Setup/Orchard.Setup.csproj b/src/Orchard.Web/Modules/Orchard.Setup/Orchard.Setup.csproj index 2e849ea53..075d62dd5 100644 --- a/src/Orchard.Web/Modules/Orchard.Setup/Orchard.Setup.csproj +++ b/src/Orchard.Web/Modules/Orchard.Setup/Orchard.Setup.csproj @@ -67,9 +67,13 @@ + + + + diff --git a/src/Orchard.Web/Modules/Orchard.Setup/Services/ISetupService.cs b/src/Orchard.Web/Modules/Orchard.Setup/Services/ISetupService.cs new file mode 100644 index 000000000..f7a985e63 --- /dev/null +++ b/src/Orchard.Web/Modules/Orchard.Setup/Services/ISetupService.cs @@ -0,0 +1,5 @@ +namespace Orchard.Setup.Services { + public interface ISetupService : IDependency { + void Setup(SetupContext context); + } +} \ No newline at end of file diff --git a/src/Orchard.Web/Modules/Orchard.Setup/Services/SetupContext.cs b/src/Orchard.Web/Modules/Orchard.Setup/Services/SetupContext.cs new file mode 100644 index 000000000..7cbf85fe3 --- /dev/null +++ b/src/Orchard.Web/Modules/Orchard.Setup/Services/SetupContext.cs @@ -0,0 +1,13 @@ +using System.Collections.Generic; + +namespace Orchard.Setup.Services { + public class SetupContext { + public string SiteName { get; set; } + public string AdminUsername { get; set; } + public string AdminPassword { get; set; } + public string DatabaseProvider { get; set; } + public string DatabaseConnectionString { get; set; } + public string DatabaseTablePrefix { get; set; } + public IEnumerable EnabledFeatures { get; set; } + } +} \ No newline at end of file diff --git a/src/Orchard.Web/Modules/Orchard.Setup/Services/SetupService.cs b/src/Orchard.Web/Modules/Orchard.Setup/Services/SetupService.cs new file mode 100644 index 000000000..ba9e8a3cf --- /dev/null +++ b/src/Orchard.Web/Modules/Orchard.Setup/Services/SetupService.cs @@ -0,0 +1,140 @@ +using System; +using System.Linq; +using System.Web; +using Orchard.Comments.Models; +using Orchard.ContentManagement; +using Orchard.Core.Common.Models; +using Orchard.Core.Navigation.Models; +using Orchard.Core.Settings.Models; +using Orchard.Data; +using Orchard.Environment; +using Orchard.Environment.Configuration; +using Orchard.Environment.Extensions; +using Orchard.Environment.ShellBuilders; +using Orchard.Environment.Topology; +using Orchard.Environment.Topology.Models; +using Orchard.Localization; +using Orchard.Security; +using Orchard.Settings; +using Orchard.Themes; +using Orchard.UI.Notify; + +namespace Orchard.Setup.Services { + public class SetupService : ISetupService { + private readonly ShellSettings _shellSettings; + private readonly IOrchardHost _orchardHost; + private readonly IShellSettingsManager _shellSettingsManager; + private readonly IShellContainerFactory _shellContainerFactory; + private readonly ICompositionStrategy _compositionStrategy; + + public SetupService( + ShellSettings shellSettings, + INotifier notifier, + IOrchardHost orchardHost, + IShellSettingsManager shellSettingsManager, + IShellContainerFactory shellContainerFactory, + ICompositionStrategy compositionStrategy) { + _shellSettings = shellSettings; + _orchardHost = orchardHost; + _shellSettingsManager = shellSettingsManager; + _shellContainerFactory = shellContainerFactory; + _compositionStrategy = compositionStrategy; + T = NullLocalizer.Instance; + } + + private Localizer T { get; set; } + + public void Setup(SetupContext context) { + var shellSettings = new ShellSettings(_shellSettings) { + DataProvider = context.DatabaseProvider, + DataConnectionString = context.DatabaseConnectionString, + DataTablePrefix = context.DatabaseTablePrefix, + }; + + var shellDescriptor = new ShellDescriptor { + EnabledFeatures = context.EnabledFeatures.Select(name => new ShellFeature { Name = name }) + }; + + var shellToplogy = _compositionStrategy.Compose(shellSettings, shellDescriptor); + + // initialize database explicitly, and store shell descriptor + var bootstrapLifetimeScope = _shellContainerFactory.CreateContainer(shellSettings, shellToplogy); + using (var environment = new StandaloneEnvironment(bootstrapLifetimeScope)) { + environment.Resolve().CreateDatabase(); + + environment.Resolve().UpdateShellDescriptor( + 0, + shellDescriptor.EnabledFeatures, + shellDescriptor.Parameters); + } + + + // creating a standalone environment. + // in theory this environment can be used to resolve any normal components by interface, and those + // components will exist entirely in isolation - no crossover between the safemode container currently in effect + + // must mark state as Running - otherwise standalone enviro is created "for setup" + shellSettings.State = new TenantState("Running"); + using (var environment = _orchardHost.CreateStandaloneEnvironment(shellSettings)) { + try { + // create superuser + var membershipService = environment.Resolve(); + var user = + membershipService.CreateUser(new CreateUserParams(context.AdminUsername, context.AdminPassword, + String.Empty, String.Empty, String.Empty, + true)); + + // set site name and settings + var siteService = environment.Resolve(); + var siteSettings = siteService.GetSiteSettings().As(); + siteSettings.Record.SiteSalt = Guid.NewGuid().ToString("N"); + siteSettings.Record.SiteName = context.SiteName; + siteSettings.Record.SuperUser = context.AdminUsername; + siteSettings.Record.PageTitleSeparator = " - "; + + // set site theme + var themeService = environment.Resolve(); + themeService.SetSiteTheme("Classic"); + + var contentManager = environment.Resolve(); + + // simulate installation-time module activation events + var hackInstallationGenerator = environment.Resolve(); + hackInstallationGenerator.GenerateInstallEvents(); + + // create home page as a CMS page + var page = contentManager.Create("page", VersionOptions.Draft); + page.As().Text = "

Welcome to Orchard!

Congratulations, you've successfully set-up your Orchard site.

This is the home page of your new site. We've taken the liberty to write here about a few things you could look at next in order to get familiar with the application. Once you feel confident you don't need this anymore, just click Edit to go into edit mode and replace this with whatever you want on your home page to make it your own.

One thing you could do (but you don't have to) is go into Manage Settings (follow the Admin link and then look for it under \"Settings\" in the menu on the left) and check that everything is configured the way you want.

You probably want to make the site your own. One of the ways you can do that is by clicking Manage Themes in the admin menu. A theme is a packaged look and feel that affects the whole site.

Next, you can start playing with the content types that we installed. For example, go ahead and click Add New Page in the admin menu and create an \"about\" page. Then, add it to the navigation menu by going to Manage Menu. You can also click Add New Blog and start posting by clicking \"Add New Post\".

Finally, Orchard has been designed to be extended. It comes with a few built-in modules such as pages and blogs or themes. You can install new themes by going to Manage Themes and clicking Install a new Theme. Like for themes, modules are created by other users of Orchard just like you so if you feel up to it, please consider participating.

--The Orchard Crew

"; + page.As().Slug = "home"; + page.As().Title = T("Home").ToString(); + page.As().CommentsShown = false; + page.As().Owner = user; + contentManager.Publish(page); + siteSettings.Record.HomePage = "PageHomePageProvider;" + page.Id; + + // add a menu item for the shiny new home page + var menuItem = contentManager.Create("menuitem"); + menuItem.As().MenuPosition = "1"; + menuItem.As().MenuText = T("Home").ToString(); + menuItem.As().OnMainMenu = true; + menuItem.As().Url = ""; + + //Temporary fix for running setup on command line + if (HttpContext.Current != null) { + var authenticationService = environment.Resolve(); + authenticationService.SignIn(user, true); + } + } + catch { + environment.Resolve().Cancel(); + throw; + } + } + + _shellSettingsManager.SaveSettings(shellSettings); + + // MultiTenancy: This will not be needed when host listens to event bus + _orchardHost.Reinitialize_Obsolete(); + } + } +} \ No newline at end of file diff --git a/src/Orchard.Web/Modules/Orchard.Setup/SetupMode.cs b/src/Orchard.Web/Modules/Orchard.Setup/SetupMode.cs index 40f71ccea..28425b688 100644 --- a/src/Orchard.Web/Modules/Orchard.Setup/SetupMode.cs +++ b/src/Orchard.Web/Modules/Orchard.Setup/SetupMode.cs @@ -3,6 +3,8 @@ using System.Collections.Generic; using System.Web; using System.Web.Routing; using Autofac; +using Orchard.Commands; +using Orchard.Commands.Builtin; using Orchard.ContentManagement; using Orchard.ContentManagement.Handlers; using Orchard.Data.Builders; @@ -14,6 +16,7 @@ using Orchard.Mvc.ModelBinders; using Orchard.Mvc.Routes; using Orchard.Mvc.ViewEngines; using Orchard.Settings; +using Orchard.Setup.Commands; using Orchard.Themes; using Orchard.UI.Notify; using Orchard.UI.PageClass; @@ -26,6 +29,7 @@ namespace Orchard.Setup { // standard services needed in setup mode builder.RegisterModule(new MvcModule()); + builder.RegisterModule(new CommandModule()); builder.RegisterType().As().InstancePerLifetimeScope(); builder.RegisterType().As().InstancePerLifetimeScope(); builder.RegisterType().As().InstancePerLifetimeScope(); @@ -37,6 +41,8 @@ namespace Orchard.Setup { builder.RegisterType().As().InstancePerLifetimeScope(); builder.RegisterType().As().InstancePerLifetimeScope(); builder.RegisterType().As().InstancePerLifetimeScope(); + builder.RegisterType().As().InstancePerLifetimeScope(); + builder.RegisterType().As().InstancePerLifetimeScope(); // setup mode specific implementations of needed service interfaces builder.RegisterType().As().InstancePerLifetimeScope(); diff --git a/src/Orchard.Web/Modules/Orchard.Setup/ViewModels/SetupViewModel.cs b/src/Orchard.Web/Modules/Orchard.Setup/ViewModels/SetupViewModel.cs index 122c38e77..cc48b2e49 100644 --- a/src/Orchard.Web/Modules/Orchard.Setup/ViewModels/SetupViewModel.cs +++ b/src/Orchard.Web/Modules/Orchard.Setup/ViewModels/SetupViewModel.cs @@ -5,9 +5,9 @@ using Orchard.Mvc.ViewModels; namespace Orchard.Setup.ViewModels { public class SetupViewModel : BaseViewModel { - public SetupViewModel() { - DatabaseOptions = true; - } + public SetupViewModel() { + DatabaseOptions = true; + } [Required(ErrorMessage = "Site name is required."), StringLength(70, ErrorMessage = "Site name can be no longer than 70 characters.")] public string SiteName { get; set; } diff --git a/src/Orchard/Commands/CommandHostAgent.cs b/src/Orchard/Commands/CommandHostAgent.cs index dbf2cbadf..184e92fc6 100644 --- a/src/Orchard/Commands/CommandHostAgent.cs +++ b/src/Orchard/Commands/CommandHostAgent.cs @@ -88,7 +88,10 @@ namespace Orchard.Commands { return 0; } catch (Exception e) { - for (; e != null; e = e.InnerException) { + for (int i = 0; e != null; e = e.InnerException, i++) { + if (i > 0) { + output.WriteLine("-------------------------------------------------------------------"); + } output.WriteLine("Error: {0}", e.Message); output.WriteLine("{0}", e.StackTrace); } @@ -100,9 +103,22 @@ namespace Orchard.Commands { if (!_tenants.ContainsKey(tenant)) { var host = _hostContainer.Resolve(); var tenantManager = _hostContainer.Resolve(); - var tenantSettings = tenantManager.LoadSettings().Single(s => String.Equals(s.Name, tenant, StringComparison.OrdinalIgnoreCase)); - var env = host.CreateStandaloneEnvironment(tenantSettings); + + // Retrieve settings for speficified tenant. In case of an unitiliazed site (no + // settings anywhere), we create a default settings instance. + var settingsList = tenantManager.LoadSettings(); + ShellSettings settings; + if (settingsList.Any()) { + settings = tenantManager.LoadSettings().Single(s => String.Equals(s.Name, tenant, StringComparison.OrdinalIgnoreCase)); + } + else { + settings = new ShellSettings {Name = "Default", State = new TenantState("Uninitialized")}; + } + + var env = host.CreateStandaloneEnvironment(settings); + + // Store in cache for next calls _tenants.Add(tenant, env); } return _tenants[tenant]; diff --git a/src/Tools/Orchard/OrchardHost.cs b/src/Tools/Orchard/OrchardHost.cs index 9368c6766..19ba0ff55 100644 --- a/src/Tools/Orchard/OrchardHost.cs +++ b/src/Tools/Orchard/OrchardHost.cs @@ -52,9 +52,6 @@ namespace Orchard { bool showHelp = _arguments.Switches.ContainsKey("?"); if (!showHelp) { showHelp = (!_arguments.Arguments.Any() && !_arguments.ResponseFiles.Any()); - if (showHelp) { - _output.WriteLine("Incorrect syntax: A command or a response file must be specified"); - } } if (!showHelp) {