Skip to content
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

Add new 'Umbraco Package RCL' project template #13460

Closed

Conversation

ronaldbarendse
Copy link
Contributor

Prerequisites

  • I have added steps to test this contribution in the description below

Description

With PR #13141 merged, packages targeting v11 can now be distributed as a Razor Class Library, removing the need for custom MSBuild targets that copy files into the Umbraco project and simplifying the reference between the package and test site project.

This PR adds a new 'Umbraco Package RCL' (dotnet new umbracopackage-rcl) project template that is basically the same as the default 'Razor Class Library' template, but includes references to the CMS and a sample package.manifest file. Developers can still choose to use existing 'Umbraco Package' (dotnet new umbracopackage) template, e.g. if they want to support an older Umbraco version.


To test, pack and install the templates from this PR using:

dotnet pack -c Release -o build.out
dotnet new uninstall Umbraco.Templates
dotnet new install build.out\Umbraco.Templates.*.nupkg

Then go to a new empty folder and create a new package including a test site using:

# Add Umbraco Prereleases NuGet feed (to install 11.0.0-rc5, can be omitted when released on NuGet.org)
dotnet new nugetconfig
dotnet nuget add source https://www.myget.org/F/umbracoprereleases/api/v3/index.json --name "Umbraco Prereleases"

# Create git repo and solution
git init
dotnet new gitignore
dotnet new sln

# Create package project
dotnet new umbracopackage-rcl --name Our.Umbraco.MyPackage --version 11.0.0-rc5 --support-pages-and-views --output src\Our.Umbraco.MyPackage
dotnet sln add --in-root src\Our.Umbraco.MyPackage

# Create test site project
dotnet new umbraco --name Our.Umbraco.MyPackage.TestSite --version 11.0.0-rc5 --minimal-gitignore --output examples\Our.Umbraco.MyPackage.TestSite
dotnet sln add --solution-folder Examples examples\Our.Umbraco.MyPackage.TestSite
dotnet add examples\Our.Umbraco.MyPackage.TestSite reference src\Our.Umbraco.MyPackage

# Commit
git add .
git commit -m "Initial commit"

# Create NuGet package and publish site
dotnet pack src\Our.Umbraco.MyPackage --configuration Release --output build.out
dotnet publish examples\Our.Umbraco.MyPackage.TestSite --configuration Release --output build.out\publish

# Run test site
dotnet run --project examples\Our.Umbraco.MyPackage.TestSite

Now inspect and ensure the following:

  • Our.Umbraco.MyPackage.1.0.0.nupkg contains the default RCL build props and the staticwebsassets folder contains the package.manifest file;
  • The RCL files are copied into the wwwroot of the published output (publish\wwwroot\App_Plugins\Our.Umbraco.MyPackage\package.manifest exists);
  • Complete the Umbraco install of the test site and ensure the package is listed under 'Packages - Installed'.

You can also do a sanity check and test whether adding tours, icons, dashboards, language files, etc. to the package works, but that is already done as part of the linked PR.

Comment on lines 4 to +6
"Framework": {
"longName": "Framework",
"shortName": "F"
"longName": "framework",
"isHidden": true
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The only allowed framework version is net7.0, so there's no need to show this parameter.

Since this value isn't supported on older Umbraco versions, any unaltered command would result in an ...is not a valid value... error, so I've also updated the capitalization to align with the default ASP.NET Core templates.

@@ -41,9 +41,16 @@
"description": "The version of Umbraco.Cms to add as PackageReference.",
"type": "parameter",
"datatype": "string",
"defaultValue": "10.0.0-rc1",
"defaultValue": "11.0.0",
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This value is automatically updated in the Azure Pipelines build script (causing the generated NuGet package to always contain the same Umbraco version number as itself), but we might want to update the source to at least the latest major version or otherwise a more generic * version...

@@ -37,7 +36,8 @@
},
{
"id": "DevelopmentDatabaseType",
"isVisible": true
"isVisible": true,
"persistenceScope": "templateGroup"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Adding this persistenceScope value will make your IDE remember the last used value, making it easier to set your preferred options once and re-use that for all future projects created from this template.

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