Skip to content

Conversation

@LottePitcher
Copy link
Contributor

@LottePitcher LottePitcher commented Nov 25, 2025

The umbraco-extension template can be called with a -ex parameter to include an example dashboard in the extension project. If this parameter is used then the extension project created by the template does not build. And this 'end-to-end' example is very useful for people to see how everything is wired up!

These errors result from changes made in #20386

Replicating the issue (with 17 RC4)

In an empty folder open the command prompt and run

# Ensure we have the version specific Umbraco templates
dotnet new install Umbraco.Templates@17.0.0-rc4 --force

# Create solution/project
dotnet new sln --name "MySolution"
dotnet new umbraco --force -n "MyProject"  --friendly-name "Administrator" --email "admin@example.com" --password "1234567890" --development-database-type SQLite
dotnet sln add "MyProject"

# Add extension project using examples flag (add to solution and project reference)
dotnet new umbraco-extension -n MyExtension -ex
dotnet sln add "MyExtension"
dotnet add reference "MyExtension/MyExtension.csproj" --project "MyProject/MyProject.csproj"

As using an RC you need to make some manual changes (downside of how the versioning is configured)

  • In MyExtension/MyExtensions.csproj - lines 17-20, manually set package reference versions (* -> 17.0.0-rc4)
  • In MyExtension/Client/package.json - line 13, manually set the version number (^* -> ^17.0.0-rc4)
# Make sure C# builds 
dotnet build

# Build front-end assets
cd MyExtension/Client
npm i
npm run build

The npm run build step will fail. This is because the template has a WebsiteClientService not a UmbracoExtensionService class specified in Client/src/api/sdk.gen.ts. The class needs to be called UmbracoExtensionService so that when the template runs it will get replaced with the name (-n) parameter.

You can fix this manually in your created project by changing the class name in sdk.gen.ts to MyExtensionService

Now npm run build should work.

# Run the website
cd ../..
dotnet run --project "MyProject"

Now test the example dashboard in the website. The buttons in the dashboard won't work because it's making calls to urls such as umbraco/websiteclient/api whereas the urls should reflect the name (-n) parameter when the template ran.

You can fix this manually by finding the occurrences of websiteclient/api and changing them to be myextension/api

Rebuild and now the dashboard buttons should work!

BTW the final test is that hey api re-generation works … With the website still running:

cd MyExtension/Client
npm run generate-client

Which it did - hey api reported successful re-generation 😅

This PR

This PR resets the incorrect instances of WebsiteClient and websiteclient back to UmbracoExtension and umbracoextension

It also resets the port number in the template to be consistently 44339 as that's the port number that the template is configured to replace, if the template is ran with the --site-domain parameter

Testing Done

I have tested these changes locally. Just to clarify I did this by (in the templates folder of my fork):

dotnet pack -o "c:\Nuget.Local"
dotnet nuget add source "c:\Nuget.Local" --name "Local Nuget"
dotnet new install "c:\Nuget.Local\Umbraco.Templates.WhateverItGenerated.nupkg"

Having installed the templates from my local nuget package, I then re-ran the rest of the testing steps above:

  • npm run build works
  • the dashboard buttons work
  • npm run generate-client work

So this is PR now tested😅

@LottePitcher LottePitcher marked this pull request as ready for review November 25, 2025 17:17
Copilot AI review requested due to automatic review settings November 25, 2025 17:17
Copilot finished reviewing on behalf of LottePitcher November 25, 2025 17:20
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes critical template placeholder inconsistencies in the umbraco-extension template that prevented it from building when the -ex (include example) parameter was used. The issues were introduced in PR #20386 and affected the auto-generated TypeScript API client files.

Key Changes:

  • Corrected service class name from WebsiteClientService to UmbracoExtensionService to align with template replacement patterns
  • Fixed API URL paths from /umbraco/websiteclient/api/... to /umbraco/umbracoextension/api/... to match controller routes
  • Updated default port from 44394 to 44339 to match template configuration

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
templates/UmbracoExtension/Client/src/api/types.gen.ts Updated port from 44394 to 44339 and corrected API URL paths from websiteclient to umbracoextension
templates/UmbracoExtension/Client/src/api/sdk.gen.ts Renamed service class from WebsiteClientService to UmbracoExtensionService and fixed API URL paths
templates/UmbracoExtension/Client/src/api/client.gen.ts Updated baseUrl port from 44394 to 44339

@AndyButland AndyButland changed the title fix placeholders and port in umbraco-extension template Dotnet new templates: Fix placeholders and port in umbraco-extension template Nov 25, 2025
Copy link
Contributor

@AndyButland AndyButland left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've replayed your testing steps @LottePitcher and all the builds now work for me too - thanks for catching this and making the update. Also for noting workarounds for the meantime, as this will need to come in 17.1.

Do you think you might transfer some of the testing steps you've noted in this PR into a README.md file that you save in the root of the \templates folder please? Can see they might be useful in future for anyone else having to make and test changes to these templates.

@LottePitcher
Copy link
Contributor Author

Until this fix is released, anyone running dotnet new umbraco-extension -n {YourName} -ex should do the following after the template has succeeded:

  • Add a reference to the newly created Extension project to your Umbraco project
  • Start your Umbraco website
  • In the Extension project
    • In Client/package.json, change the port number on line 9 to be the correct port for your website
    • From the Client folder:
      • npm i
      • npm run generate-client - this should correctly regenerate the TypeScript files
      • npm run build

Now re-start your Umbraco website and the example dashboard should work!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants