RichardSoeteman.NET

Auto install latest Umbraco 14

Published 16 November 2023

The upcoming months I will be experimenting a lot with the new Backoffice. To quickly generate a development site I created a small Powershell script that generates a new Umbraco V14 site and install the latest Client scripts for Typescript development.

Let's start with adding a refererence to the Umbraco feed

Using the following script you will add a reference to the Umbraco nightly feed location, this ensures we get the latest Umbraco V14 version.

#Add prerelase feed location 
dotnet nuget add source "https://www.myget.org/F/umbracoprereleases/api/v3/index.json" -n "Umbraco Prerelease"
Create new Umbraco Site

Next we will be creating the testsite . I am using the Umbraco unattended install option to quickly create the site and use LocalDB as a database. I don't worry about the username and password, these sites will never see the day of light

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

cd BellissimaNightlySite 
#Set info for installer
Set-Item Env:\UMBRACO__CMS__GLOBAL__INSTALLMISSINGDATABASE true
Set-Item Env:\UMBRACO__CMS__UNATTENDED__INSTALLUNATTENDED true
Set-Item Env:\UMBRACO__CMS__UNATTENDED__UNATTENDEDUSERNAME "Soeteman Software Test User"
Set-Item Env:\UMBRACO__CMS__UNATTENDED__UNATTENDEDUSEREMAIL "testuser@soetemansoftware.nl"
Set-Item Env:\UMBRACO__CMS__UNATTENDED__UNATTENDEDUSERPASSWORD "test123456"

#build site including dependencies
dotnet build
Add Client folder for Lit development

Next up is creating a client project using npm that will generate the project files for me. After that you can directly start developing your extension as mentioned in the documentation.

mkdir "client-src"
cd  "client-src"
npm create vite@latest my-extension -- --template lit-ts 
cd my-extension
npm install
npm install -D @umbraco-cms/backoffice

cd ../../
#start site
dotnet run
Complete Script

This is the complete script you can run to setup the environment.

#Add prerelease feed location 
dotnet nuget add source "https://www.myget.org/F/umbracoprereleases/api/v3/index.json" -n "Umbraco Prerelease"

#Create new Umbraco Site
dotnet new install Umbraco.Templates::14.0.0-beta002

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

cd BellissimaNightlySite 
#Set info for installer
Set-Item Env:\UMBRACO__CMS__GLOBAL__INSTALLMISSINGDATABASE true
Set-Item Env:\UMBRACO__CMS__UNATTENDED__INSTALLUNATTENDED true
Set-Item Env:\UMBRACO__CMS__UNATTENDED__UNATTENDEDUSERNAME "Soeteman Software Test User"
Set-Item Env:\UMBRACO__CMS__UNATTENDED__UNATTENDEDUSEREMAIL "testuser@soetemansoftware.nl"
Set-Item Env:\UMBRACO__CMS__UNATTENDED__UNATTENDEDUSERPASSWORD "test123456"

#build site including dependencies
dotnet build

mkdir "client-src"
cd  "client-src"
npm create vite@latest my-extension -- --template lit-ts 
cd my-extension
npm install
npm install -D @umbraco-cms/backoffice

cd ../../
#start site
dotnet run


write host "Done, visit https://docs.umbraco.com/umbraco-backoffice/tutorials/creating-your-first-extension to continue developing"

References

The following references will give you more details about all steps taken in this script.

Hope you can use this Powershell script as well to quickly generate trial environments.