Umbraco 9 Useful Snippets

Posted written by Paul Seal on September 17, 2021 Umbraco

This is just a simple post for me to update and come back to as a reference when working with v9.

This installs a valid dev certificate for using localhost with https

dotnet dev-certs https --trust

This clears the local nuget cache

dotnet nuget locals all --clear

This is the v9 dev branch appsettings.json file if I ever want to do PR for it

https://github.com/umbraco/Umbraco-CMS/blob/v9/dev/build/templates/UmbracoProject/appsettings.Development.json

If you want the site to run and build when changes are made whilst it is running you can use this

dotnet watch run

From the Discord Server. Ronald said this:

If you like the CLI, this is a great way to get started with RC4, LocalDB and The Starter Kit

# Ensure we have the latest Umbraco templates
dotnet new -i Umbraco.Templates

# Create solution/project
dotnet new sln --name MySolution
dotnet new umbraco -n MyProject --friendly-name "Admin User" --email "<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="355451585c5b755451585c5b1b565a58">[email&#160;protected]</a>" --password "1234567890" --connection-string "Data Source=(localdb)\MSSQLLocalDB;AttachDbFilename=|DataDirectory|\Umbraco.mdf;Integrated Security=True"
dotnet sln add MyProject
dotnet add MyProject package Portfolio

# Run
dotnet run --project MyProject

If you would prefer to use SQLCE you can just change the connection string and add the -ce flag like this:

# Ensure we have the latest Umbraco templates
dotnet new -i Umbraco.Templates

# Create solution/project
dotnet new sln --name MySolution
dotnet new umbraco -n MyProject --friendly-name "Admin User" --email "<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="0362676e6a6d4362676e6a6d2d606c6e">[email&#160;protected]</a>" --password "1234567890" --connection-string "Data Source=|DataDirectory|\Umbraco.sdf;Flush Interval=1" -ce
dotnet sln add MyProject
dotnet add MyProject package Portfolio

# Run
dotnet run --project MyProject

If you are experiencing examine issues after installing RC4, it could be a nuget caching issue. Try this from Warren:

dotnet nuget locals all -clear
dotnet restore
dotnet build
dotnet run

Ronald also told us this:

We don't need to specify --SqlCe anymore and it works with unattended install as well, so you can already provide a connection string, set the Umbraco:CMS:Unattended settings and have Umbraco create the database file, install the database tables, create the local user and have an Umbraco backoffice ready to login on the first request!

Adding field definitions in Examine

https://shazwazza.github.io/Examine/configuration

Then add it in startup like this

https://github.com/umbraco/Umbraco-CMS/blob/v9/dev/src/Umbraco.Examine.Lucene/DependencyInjection/UmbracoBuilderExtensions.cs#L31