Can you run orchard setup from command line?

Topics: Administration, Core, General, Installing Orchard
Jan 11, 2012 at 5:04 PM

I'm starting from a fresh install pretty often and it's getting annoying to fill out the setup screen each time. 

Is it possible to script out the setup? This way I could make an msbuild task to kill all connections and run my script to drop and recreate the DB, delete app_Data and Media/Default folders, and then run the setup with my customized parameters for recipe, connection string, etc. 

Jan 12, 2012 at 8:10 PM
Edited Jan 12, 2012 at 8:10 PM

Found the command by looking at the Orchard.Setup project (/Commands/SetupCommand.cs). When I tried "help commands" earlier it didn't display the setup stuff, I'm guessing because the Setup module is disabled once the site is set up? 

Here's the syntax:

 

setup /SiteName:<siteName> /AdminUsername:<username> /AdminPassword:<password> /DatabaseProvider:<SqlCe|SQLServer> /DatabaseConnectionString:<connection_string> /DatabaseTablePrefix:<table_prefix> /EnabledFeatures:<feature1,feature2,...> /Recipe:<recipe>
Jan 12, 2012 at 8:42 PM

Quick and dirty script to bomb and rehydrate an orchard instance (with my luck this already exists somewhere in the source): 

rehydrate.bat

taskkill.exe /IM WebDev.WebServer40.EXE
rmdir App_Data /S /Q
rmdir Media\Default /S /Q
osql.exe -E -S localhost -i "Recreate_Orchard1x_db.sql"
bin\Orchard.exe setup <your orchard setup options>

Mar 12, 2013 at 3:39 PM
Sorry for bumping an old post but this is exactly what I am trying to accomplish. Every time I create a site from the command line then run it in VS 2012, I get a controller error complaining it can't find the virtual directory. If I remove the Virtual Path from Properties->Web under Visual Studio Development Server, I still get an error in ShellRoute.BeingProcessRequest saying it can't find the route '/'.

Any thoughts on how I can get around this? Scripting these setups is essential for development teams so I am sure someone is doing it... I just can't see what I am doing wrong.
Mar 28, 2013 at 9:06 PM
Are you using the default recipe when you run setup from command line? What's the actual error message you get when running the site? Are you running Visual Studio with Admin rights? Are there any errors i App_Data\Logs\ immediately after you've run the command line setup?
Mar 28, 2013 at 9:14 PM
I have tried it with both a custom recipe and the default recipe.

I will try this again and give you the actual error however I have discovered some errors that occur when creating a site with a recipe end up leaving you with a 404 error as though the site simply doesn't exist. Not sure why that is.

Seems the site creation from a recipe bit has some issues though I haven't been able to pinpoint them accurately.

As for running VS as admin, yes.
Errors in \Logs.. no... just an empty log file.

At the moment I am working around this by running and creating from a recipe though it would be nice to be able to do a CL setup for dev purposes.
Mar 28, 2013 at 9:22 PM
Hmm, I am not having any problems creating a site from recipe. I base my recipes either off of Default, Core, or Blog, and then heavily customize them. They all work for me. I'm basically doing exactly what you are trying to do -- script out the site creation so I can start from scratch at any time by running a command line script. Since the above post I have upgraded my rehydrate script to become a powershell script. It's a little more reliable in terms of killing tasks and you can use a ton more commands than are available from batch files.

If you post the scripts you are using, and the recipes (if you've modified them), and the error(s) you get, we'll be able to help. Also mention which version of the code you're using.
Jul 3, 2014 at 8:12 PM
I ran into this problem in Orchard 1.x when I had a recipe that used the page create command to add the page to a menu. The command worked fine when the setup was done via the website but blew up when executed from the command line.

Here's an example of a command that causes the setup recipe to fail on the command-line:
page create /Slug:"welcome-to-cider" /Title:"Welcome to Orchard!" /Path:"welcome-to-orchard" /Homepage:true /Publish:true /UseWelcomeText:true /MenuText:"Home" /MenuName:"Main Menu"
The recipe fails with a null reference exception in the log.