Improve dotnet templates#16815
Merged
Merged
Conversation
We don't need write access to this folder
The compose file is intended to be used for local dev
Still not great to store it in .env but it's fine for dev
otherwise it won't work with Rider, also make the version 13.0.0 if LTS is chosen
Otherwise, rider will use UmbracoVersion for some weird reason
You still want to be able to use non-https when developing locally
LTS still needs installer endpoints added
1 task
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
New functionality
Enable delivery API
This is added as a flag, if enabled this will add the
.AddDeliveryApi()toProgram.csand enable the delivery API inappsettings.jsonthis also means that if the flag is not enabled.AddDeliveryApi()will not be added toProgram.csanymore, which has the added benefit that it won't be shown in the swagger docs either, currently we are documenting a non-existing API in that case.Example
dotnet new umbraco -n MySite -daChoose models builder mode
This option allows you to specify the models mode from the dotnet new template, and additionally enables
RazorCompileOnBuildandRazorCompileOnPublishifInMemoryAutoisn't selected.Note
If
IDEDevelopmentis selected as development mode, this option only changes the modelsbuilder mode inappsettings.development.jsonExample
dotnet new umbraco -n MySite -mm SourceCodeAutoInstall starter kit
This option allows you to install a starter kit from a selection when installing Umbraco. Currently, the only option is the official starter kit, but this can be extended to include community starter kits as well. It's worth noting that this configuration is split into its own template file starterkits.template.json to make adding starter kits easier.
Example
dotnet new umbraco -n MySite -sk TheStarterKitChoose development mode
Allows you to specify the runtime modes you want to use, you have two options here.
appsettings.Development.jsontoDevelopmentruntime mode andSourceCodeAutomodels builder mode, and configuresappsettings.jsontoProductionruntime mode,Nothingmodels builder mode, and enablesUseHttpsNote
It's still necessary to manually set
Umbraco:CMS:WebRouting:UmbracoApplicationUrlinappsettings.jsonwhen using IDE Development mode.Example
dotnet new umbraco -n MySite -dm IDEDevelopmentChoose release type
Allows you to specify which release type you want to install
Note
With the introduction of this new parameter the old
UmbracoVersionhas been deprecated and hidden in favour of release type.Important
This means that from this point on we have to update our templates when we make a new LTS, to ensure that a template installs the latest LTS for that template, there is also a limitation here that the template can only install the latest versions from the time of the template release, so it'll still be necessary to manually update your templates.
Example
dotnet new umbraco -n MySite -r LTSDocker support
Adds Docker support to the template. This comes in two parts
--add-docker parameter
Adds a
Dockerfileand.dockerignoreto the project, this is by and large a pretty standard dotnet Docker file with one exception. This Dockerfile will recreate theumbracoandumbraco/Logsfolders, and runchownfor the docker user, the reason for this is that it's ideal to have these folders as volumes, however when the Docker daemon creates these folders it'll do so as therootuser, this means that Umbraco won't be able to write logs, modelsbuilder and so on to these files, which it needs to do.umbraco-compose template
In addition to the docker parameter a new item template has been added
umbraco-composethis template will add a couple of files to the current folder.Important
Due to a know issue with the azure-sql-edge the docker-compose file currently doesn't work on mac, see known issue on https://hub.docker.com/r/microsoft/azure-sql-edge
Debug, and sets theASPNETCORE_ENVIRONMENTtoDevelopmentCaution
The umbraco-compose template is intended for local development, and should not be used for production, it is not advisable to have your database password in a .env file in production, it is however considered acceptable for local development.
Parameters
Example
Testing
Prerequisites
Docker installed.
A local Nuget feed:
\Github\LocalFeeddotnet nuget add source "C:\Users\NikolajELauridsen\Documents\Github\LocalFeed" -n "Local Feed"Building and testing templates
dotnet pack umbraco.sln -o Build.OutThis will put the files in aBuild.OutfolderBuild.Outinto your local feed folder, created in the prerequisitesdotnet new install Umbraco.Templates::14.2.0--rc.preview.0.gdfa8ff6(Replace the version with the one specified in your files), I.E.:Umbraco.Cms.14.2.16--rc.preview.0.gdfa8ff6has a version of14.2.16--rc.preview.0.gdfa8ff6dotnet new umbraco -n "MyAwesomeProject"Caution
Beware of the Nuget cache. Nuget will want to cache your packages, so if you don't see your changes peak through, this is likely because of the cache.
Docker and local templates
If you're working on the docker or docker-compose files, you likely want to run the project created by the template in docker, but there's a caveat here. The docker container needs access to your locally compiled Nuget files to run the restore, however, the docker image does not have access to your files system, and cannot get access to your local Nuget feed.
There is a workaround though
First off add the following two lines just before the
RUN dotnet restoreline in the Dockerfile:This will copy the contents of the Localfeed folder into the container, and then add a local source from that folder in the container, meaning it can now find the local Nuget files.
Important
The
LocalFeedfolder must be in the same folder as the docker-compose file.Now you can run the compose with:
docker compose up