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 #13776

Merged
merged 5 commits into from
Apr 5, 2023

Conversation

ronaldbarendse
Copy link
Contributor

This is basically identical to PR #13460 that was automatically closed when 11.0 was released and the release/11.0 branch got deleted.


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 the 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:

# 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 --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 --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 11
"Framework": {
"longName": "Framework",
"shortName": "F"
"longName": "framework",
"isHidden": true
},
"UmbracoVersion": {
"longName": "version",
"shortName": "v"
"shortName": ""
},
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 (for now), 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.

Similarly, .NET 7 introduced a new verbosity option, taking the v short name, resulting in having to use -p:v for the Umbraco version instead. To remove any confusion, only allowing --version seems like a better idea.

Copy link
Member

Choose a reason for hiding this comment

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

I just fear if the change in long name is breaking anyones buildscripts. That change should IMO only be for v12

Copy link
Member

Choose a reason for hiding this comment

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

@ronaldbarendse I agree with Bjarke here, could you make a separate PR for this change targeting v12? I know we already bumped this to v11, so lets get it done now, so we don't keep pushing this change back 😁

Copy link
Contributor Author

@ronaldbarendse ronaldbarendse Apr 4, 2023

Choose a reason for hiding this comment

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

I've reverted the changes to the Framework and UmbracoVersion parameter names, so this isn't breaking anymore. The Framework parameter will now be hidden though, since only net7.0 is a valid value: we can show it again when net8.0 gets added and there's an actual choice to make 😉

The new umbracopackage-rcl template won't have the v short name, since we know it already clashes with the verbosity option and will be removed in v12 anyway...

@Zeegaan
Copy link
Member

Zeegaan commented Apr 5, 2023

Looks good, tests good 🚀

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

Successfully merging this pull request may close these issues.

3 participants