Templates: Add optional Central Package Management support to UmbracoProject and UmbracoExtension templates#21641
Conversation
|
This looks good @NguyenThuyLan, but I'm having trouble testing it. I think it's a problem on my side, as I have the same problem when I test from
Here I add a
Umbraco will then build and run, but I don't get the install screen come up and all static assets requested are returning 404. |
|
Oh, I got the same issue, @AndyButland the reason is that you forgot to run Follow these steps:
|
|
Thanks @NguyenThuyLan - I still couldn't get it working from a local Let's pause to get @LottePitcher and @nul800sebastiaan's feedback on whether this should be applied to the extension template too. As you noted:
For new projects, and consistency though, it would make sense to use the From my side I just wondered if this should be (or could be?) an option - so the user of the template has the option to decide which package management approach they want. Maybe you could consider how feasible that is. |
|
@AndyButland , Oh I think that's a good idea. What about adding a
|
|
Let's try it - at least see if it works and doesn't make the template too complicated. It should consistent for the project and extension template though - so the option should exit for both. Sounds to me that it's nice to be an option, and also doesn't "break" anything for people that are using it. * Of course it's not breaking in the normal sense, as templates are for new projects, but it might change expectations for people using it, or new projects spun up on Umbraco Cloud, if we make CPM the default. |
|
I updated my PR and also the description to add this parameter option. |
There was a problem hiding this comment.
I like that this is an option now @NguyenThuyLan, and consistent for both templates.
I think we should align the naming of the parameter with other ones, and ensure it's exposed to the CLI. So we have -p and --package-management (aligning for example with -da and --use-delivery-api in casing),
templates/UmbracoProject/.template.config/dotnetcli.host.json — add entry in symbolInfo:
"PackageManagement": {
"longName": "package-management",
"shortName": "pm"
}templates/UmbracoExtension/.template.config/dotnetcli.host.json — same entry:
"PackageManagement": {
"longName": "package-management",
"shortName": "pm"
}I think "Traditional" as a name might not be the best (someone unfamiliar with CPM may not understand what "traditional" means in this context). Shall we go with "PerProject" instead?
Although the information in readme.md is useful, I think we can remove it now we've made CPM an option. We can safely assume that someone opting into this will be familiar with the feature. Also, as we are only explaining this single feature and not the template as a whole, it sems a bit odd to include.
|
All looks good to me now, thanks @NguyenThuyLan. @nul800sebastiaan and @LottePitcher - as you raised and/or had comments on the discussion that led to this update, before we merge this, please could you have a look over to make sure it meets your expectations? |
|
There is an issue at the moment if you call the template with the combination of If you do that, then This fails as floating versions aren't allowed with CPM: Now whether anyone would actually do this combination I don't know. It's fixed by adding to
@NguyenThuyLan I can see you have already added this flag to the file in the Extensions template. Should we enable floating versions on the Umbraco project template too? Or let people figure their own work around if they do choose this combination and generate the error? |
For the project template I think we have to do everything we can that this "just works". The extension is for more advanced developers, who perhaps can figure things out, but the project one is the way to install Umbraco for everyone. So I think this either has to work with floating versions - which would be ideal - or we install specific versions of 17 (and have to make sure we update the template with the latest 17 version every time we release an update of that major). |
|
Thank you @LottePitcher for pointing that out. |
|
I realise I'm not seeing the option presented for selection when I try to use the template in Visual Studio @NguyenThuyLan - I would have expected to see it here:
It looks like entries in the two |
AndyButland
left a comment
There was a problem hiding this comment.
Works nicely from the command line - I've created projects with both options and they are setup as expected and build and run fine.
I realise I'm not seeing the option presented for selection when I try to use the template in Visual Studio though @NguyenThuyLan - I would have expected to see it here:
It looks like entries in the two ide.host.json files are missing.
Co-authored-by: Andy Butland <abutland73@gmail.com>
Co-authored-by: Andy Butland <abutland73@gmail.com>
Co-authored-by: Andy Butland <abutland73@gmail.com>
AndyButland
left a comment
There was a problem hiding this comment.
Looks good and works nicely now @LanThuyNguyen - I've tested the various configurations via the CLI and IDE, I'm seeing the expected projects generated, and have verified that they build.

Description
Idea: #21333
--PackageManagement (-P)template parameter with two choices:PerProject(default) andCentral, allowing users to opt intohttps://learn.microsoft.com/en-us/nuget/consume-packages/central-package-management when scaffolding new projects
Central" is selected, aDirectory.Packages.propsfile is generated and.csprojpackage references omit version attributes; when "PerProject" isselected (default), the existing behavior is preserved with versions inline in the
.csprojUmbracoProjectandUmbracoExtensiontemplates, with the extension template additionally enablingCentralPackageFloatingVersionsEnabledso extensions can align with the host project's package versions.Nuget package versions per project
dotnet new umbraco -pm PerProjectordotnet new umbraco-extension -pm PerProjectWith Central Package Management (default)
dotnet new umbracoExtension with CPM (default)
dotnet new umbraco-extensionTest plan
dotnet new umbraco -pm PerProjectand verify noDirectory.Packages.propsis created,.csprojhas versions inlinedotnet new umbraco(default) and verifyDirectory.Packages.props is generated,.csprojhas no version attributesdotnet new umbraco-extension -pm PerProjectand verify noDirectory.Packages.propsis created,.csprojhas versions inlinedotnet new umbraco-extension(default) and verify CPM output withCentralPackageFloatingVersionsEnableddotnet buildsucceeds for generated projects in both modes