Movatterモバイル変換


[0]ホーム

URL:


Skip to content
DEV Community
Log in Create account

DEV Community

Kevin Jump
Kevin Jump

Posted on

     

Umbraco Setup/teardown PowerShell scripts.

Umbraco 9 embraces dotnet core and all the goodness that brings; This includes creating your umbraco site from the command line:

dotnet new umbraco -n myUmbracoSite
Enter fullscreen modeExit fullscreen mode

which is super cool, and after some intial setup screens you will have your new Umbraco site up and running locally.

How fast can you go?

So a while back this meant Igot into invented a whole Umbraco speed run challenge.

And it resulted in me writing some PowerShell scripts that allow me to setup and tear down Umbraco sites really quickly (around 30-40 seconds).

Now I have shared these scripts before, but I've updated them a bit since then and I need to update what they do.

gist script is here


The Setup

If you save that file somewhere on your computer. You can then import this module into your powershell command line.

Import-Module -Name C:\Source\Tools\umbraco-tools.psm1
Enter fullscreen modeExit fullscreen mode

If you place that line in your profile.ps1 file (usually documents\powershell\profile.ps1) it will be avalible everytime you start up a terminal.

For unattended install to work, you need to create three environmental variables on your PC

UMB_USER
UMB_EMAIL
UMB_PASSWORD


The commands

With the script installed you get three new commands.

new-umbraco  // create an new umbraco siteremove-umbraco // remove an umbraco site (and the db)clear-umbracodbs // remove all dbs
Enter fullscreen modeExit fullscreen mode

> New-Umbraco

Creates a new umbraco site installs packages, and sets up unattended installtion (so you don't have to do the setup afterwards)

New-Umbraco <SITE_NAME> [options]-n name        name of the project-p package     list of packages to install-f framework   framework to use (default .net5)-nostarter     don't install the starter kit package -donotrun      don't immediately run the site when complete-prerelease    fetch pre-release versions of any packages we ask for
Enter fullscreen modeExit fullscreen mode

For Example:
I do this quite often when testing: Create a new site, don't install the starter kit, install uSync package and open the site in VsCode when you have finished.

New-Umbraco MyNewSite -noStarter -packages uSync -code
Enter fullscreen modeExit fullscreen mode

Usually this is super fast and I can start work right away.

> Remove-Umbraco

Remove an Umbraco installation from disk and remove the db.

Remove-Umbraco <SITE-NAME> -RemoveFolder-n name          name of site-RemoveFolder    also delete the folder for the umbraco site
Enter fullscreen modeExit fullscreen mode

> Clear-UmbracoDbs

through the scripts all umbraco databaswes are created with an umb- prefix, so theClear-UmbracoDbs command simply removes all these dbs from your local instance, good if you know you've just created a load of trash dbs you need to get rid off.

Top comments(2)

Subscribe
pic
Create template

Templates let you quickly answer FAQs or store snippets for re-use.

Dismiss
CollapseExpand
 
rsoeteman profile image
rsoeteman
  • Joined

Hi Kevin,

Realy cool example how to use Powershell and .net CLI to create Umbraco sites. I am using this as well to setup testsites for my products, really fast now. Last week I found out it was really easy to use LocalDB for new sites as well.

dotnet new umbraco -n $sitename --connection-string "Server=(localdb)\MSSQLLocalDB;AttachDbFilename=|DataDirectory|\Umbraco.mdf;Integrated Security=true"

Reading your GIST reminds me, Need to learn more PowerShell :-) #h5yr

CollapseExpand
 
kevinjump profile image
Kevin Jump
part time, full time umbraco package developer
  • Location
    Liverpool, England
  • Work
    Jumoo
  • Joined

yeah - i think this ended up using SQL for the speed (i was speed running!) so on my pc its 10/15 seconds faster to use SQL. but for anything i want to be portable im using LocalDB

Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment'spermalink.

For further actions, you may consider blocking this person and/orreporting abuse

part time, full time umbraco package developer
  • Location
    Liverpool, England
  • Work
    Jumoo
  • Joined

More fromKevin Jump

DEV Community

We're a place where coders share, stay up-to-date and grow their careers.

Log in Create account

[8]ページ先頭

©2009-2025 Movatter.jp