-
Notifications
You must be signed in to change notification settings - Fork 2.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve dotnet templates #16815
Merged
Merged
Improve dotnet templates #16815
Conversation
This file contains 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
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
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.cs
and enable the delivery API inappsettings.json
this also means that if the flag is not enabled.AddDeliveryApi()
will not be added toProgram.cs
anymore, 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 -da
Choose models builder mode
This option allows you to specify the models mode from the dotnet new template, and additionally enables
RazorCompileOnBuild
andRazorCompileOnPublish
ifInMemoryAuto
isn't selected.Note
If
IDEDevelopment
is selected as development mode, this option only changes the modelsbuilder mode inappsettings.development.json
Example
dotnet new umbraco -n MySite -mm SourceCodeAuto
Install 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 TheStarterKit
Choose development mode
Allows you to specify the runtime modes you want to use, you have two options here.
appsettings.Development.json
toDevelopment
runtime mode andSourceCodeAuto
models builder mode, and configuresappsettings.json
toProduction
runtime mode,Nothing
models builder mode, and enablesUseHttps
Note
It's still necessary to manually set
Umbraco:CMS:WebRouting:UmbracoApplicationUrl
inappsettings.json
when using IDE Development mode.Example
dotnet new umbraco -n MySite -dm IDEDevelopment
Choose release type
Allows you to specify which release type you want to install
Note
With the introduction of this new parameter the old
UmbracoVersion
has 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 LTS
Docker support
Adds Docker support to the template. This comes in two parts
--add-docker parameter
Adds a
Dockerfile
and.dockerignore
to the project, this is by and large a pretty standard dotnet Docker file with one exception. This Dockerfile will recreate theumbraco
andumbraco/Logs
folders, and runchown
for 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 theroot
user, 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-compose
this 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_ENVIRONMENT
toDevelopment
Caution
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\LocalFeed
dotnet nuget add source "C:\Users\NikolajELauridsen\Documents\Github\LocalFeed" -n "Local Feed"
Building and testing templates
dotnet pack umbraco.sln -o Build.Out
This will put the files in aBuild.Out
folderBuild.Out
into 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.gdfa8ff6
has a version of14.2.16--rc.preview.0.gdfa8ff6
dotnet 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 restore
line 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
LocalFeed
folder must be in the same folder as the docker-compose file.Now you can run the compose with:
docker compose up