[WIP] Contentment for Umbraco 9 #105
Replies: 21 comments 25 replies
-
Following the Umbraco 9 Beta blog post, I followed the instructions and got a demo site up and running. https://umbraco.com/blog/umbraco-9-beta-release/ Well, I had to do it twice as I wanted to use SQLCE, and the instructions about the OK, cool, I had a demo test site up and running! 🌟 Now I need some kind of VS project for my package... From reading @AndyButland's series of blog posts, I had no idea how to swap my current .NET Framework https://www.andybutland.dev/2021/03/umbraco-package-migration-to-net-core.html When I opened Visual Studio, there was a template for "Umbraco Package", which I kinda recall various people mentioning... okay, let's go with that. All good! 🌟 But hold on. How do I get my package code/file over to my test site? For all my old packages (including Contentment for Umbraco 8) I've used some post-build XCOPY hack to put files in the right place. But that didn't feel like a very modern way of doing it, and I didn't want to immediately fall into my old habits, so searched around. 🧐 I looked over @AndyButland's Personalisation Groups repo: https://github.com/AndyButland/UmbracoPersonalisationGroupsCore but didn't see anything obvious about copying files to a test site. Ah yes, @KevinJump has been super-duper-quick to get a uSync 9 Beta released, surely he'll have something in his repo: https://github.com/KevinJump/uSync8/tree/core/main ... and his did! But I had no idea what was going on. I'm sure it makes sense, but it be simpler than having to dig deep into fellow developer's code. That's me falling straight into old habits again. 🧙 I start googling around for various Umbraco + .NET Core + Packages + Templates keywords. I eventually find this page on the Our Umbraco documentation... https://our.umbraco.com/documentation/UmbracoNetCoreUpdates#package-development Seems obvious now, but honestly, I hadn't thought of looking on there - even when there's a prominent message on the main documentation landing page pointing folk in the right direction. Again, old habits! 🤦♂️ OK, the documentation explains it all. Everything I'd done previous was a "false start" - I wiped it and followed instructions. I used the "Full example" code snippet, provided here: https://our.umbraco.com/documentation/UmbracoNetCoreUpdates#full-example But it failed, threw an error. Something was missing... various OK cool, let's create a new Package project and associated test site! 🌟
Ah no, got another error! Something about the template, and to check I took a pause, to go send a pull-request to update the documentation... umbraco/UmbracoDocs#3146 ...the journey continues... |
Beta Was this translation helpful? Give feedback.
-
hi, the stuff in the uSync repo is a bit more complicated (and old) than it needs to be. but in essence i have a gulp script that watches the app_plugins folder and copies the files into the other project when i change them. This means you don't need to build when you update front end files, infact you can have the site running and refreshing the browser is enough. the scripts can be set to run on project open (in visual studio) so they aren't something you need to remember about. a simpler implimentation is in the (v8) package templates this version reads a paths.json file from the same folder - so in theory all you need do is change the paths in that file and the script will copy things where yo need them to be. |
Beta Was this translation helpful? Give feedback.
-
... Day 2 (part 1) ... Now with a working project for the package code and a test site to try it out on, I wanted to start off with something small, then work my way up. First up, add custom CSS. Pretty straight forward, add a stylesheet, reference it in the Stylesheet .navigation-inner-container { background-color: pink; } package.manifest {
"css": [ "~/App_Plugins/Contentment9/contentment.css" ]
} Yup, works as expected. The left side nav panel is a lovely pink. 🌟 Next up, passing server-side data to CMS backoffice. In Contentment, I have a tree dashboard where I list various things about the package. In it's simplest state, if I wanted to pass the package's version number, I'd use the
I couldn't find any docs about what to use instead of The Composer pattern is still being used, I understand that one, so it goes like this... Composer internal sealed class ContentmentComposer : IUserComposer
{
public void Compose(IUmbracoBuilder builder)
{
builder.AddNotificationHandler<ServerVariablesParsing, ContentmentServerVariablesParsing>();
}
} The internal sealed class ContentmentServerVariablesParsing : INotificationHandler<ServerVariablesParsing>
{
public void Handle(ServerVariablesParsing notification)
{
notification.ServerVariables.Add("contentment", "9.0.0-h5yr");
}
} ...and when I check the CMS backoffice response using Chrome's DevTools, I search the Network tab for the "ServerVariables" request, check the JSON output and yup, the "contentment" entry is there! 🌟 Next up, add a property-editor. Still starting off small, I'm going with Notes first before working up to the more complex ones. I'll try this after lunch. ...the journey continues... |
Beta Was this translation helpful? Give feedback.
-
... Day 2 (part 2) ... Next up, add a property-editor. The simplest one is the read-only Notes editor. Despite it being a basic property-editor, the configuration is still done in C# as opposed to in the My Everything was looking good, until I got down to my implementation of the Once all compiled and copied over, it ran file. I hit a few snags, mostly to do with resolving the path of the View = _ioHelper.ResolveRelativeOrVirtualUrl("~/App_Plugins/Contentment9/notes.html")
Once the paths were all correct, the DataType could be created, configured, added to a DocType and used on Content nodes. 🌟 Next up, planting a Tree. 🌲 Contentment has a tree dashboard, where I list various information about the package itself. I took the code from Firstly, the constructor for the My tree was showing up in the Settings section! 🌟 Now that I have a feel for the types of changes that are required, I'm wondering whether I should take a stab at the whole package? Copy in all the existing code and see what doesn't compile, make the relevant amends - sounds like it's mostly adding constructor parameters - see how it goes. 🤔 See what I think in the morning. ...the journey continues... |
Beta Was this translation helpful? Give feedback.
-
... Day 3 (part 1) ... (probably the only part) 🤣 Yesterday evening I was thinking about my current Contentment repo, and would it be really that difficult to switch the By closely following the links from Andy's post, (this one and that one), I was able to reduce down the ...to... <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<Product>Umbraco.Community.Contentment</Product>
<PackageId>Our.Umbraco.Community.Contentment</PackageId>
<Title>Contentment for Umbraco</Title>
<Description>Contentment, a collection of components for Umbraco 8.</Description>
<PackageTags>umbraco</PackageTags>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Umbraco.Cms.Web.Website" Version="9.0.0-beta001.20210427.20" />
<PackageReference Include="Umbraco.Cms.Web.BackOffice" Version="9.0.0-beta001.20210427.20" />
</ItemGroup>
</Project> Not bad, over 500 lines reduced down to about 15. 😀 🌟 OK, there was a little bit of trial-and-error on which Now, Visual Studio opens the solution... 🌟 let's hit F5 and see the body count... ❌ 646 errors, Okay, the ingredients are ready, let's get cooking! 🧑🍳 ...the journey continues... |
Beta Was this translation helpful? Give feedback.
-
... Quick update at the end of Day 3 (well, half day really)... I'm down to... (drum roll please) 🥁 325 errors! So far, there are many, many namespace amends. A lot of things that were under "Umbraco.Core" are now under "Umbraco.Cms.Core". Another one that I've been changing is that ...and lastly (for today), I seem to use |
Beta Was this translation helpful? Give feedback.
-
... Day 4 (part 1) ... (It's a public holiday in the UK, kids are busy so I had a little free time) Worked through all of the errors! All gone! 🌟 Various pain points... in no particular order... Seems that I use the In a my API controllers, I'd been using I'd noticed that an extension method for adding All the assembly attributes, e.g. I had to exclude/comment-out a few classes for the Content Blocks preview feature, I was doing some funky stuff with the With my Telemetry code, I was using Once I'd resolved all the errors, the project compiled successfully! 🌟 Next to try it on the test website. Since I'd ended up migrating my existing Visual Studio The "App_Plugins" folder is in there (in the root) and the But when I try to run the website with
...and at that point, I have no idea what went wrong. Answers on a postcard please. 🙏 Guess I need to start removing code, re-compile, try it out, rinse-and-repeat! Oh, does ...the journey continues... |
Beta Was this translation helpful? Give feedback.
-
OK, figured out a workaround to the The issue has a reference to a .NET Core issue, with "probing paths", e.g. where the web-app will attempt to load in the assemblies from. Meaning that if the web-app isn't aware of the assembly, then it wont load it, (well at least not from using the So, my workaround. The comments on the .NET Core issue mention the The contents of the file will list all the dependencies of the web-app, including references to DLL paths, NuGet packages, etc. It's about 258Kb, so there's a fair amount of data in there. So I added a references for my Contentment DLL, like so...
Now, when I Of course, this isn't an ideal scenario for ongoing package development, but at least it wasn't a complete show-stopper and I can continue with the migration/testing. |
Beta Was this translation helpful? Give feedback.
-
... Day 5 update ... I mention in the comments of my previous update about the dev workflow of trying to XCOPY updates from my project to the target web-app have been quite painful. I'm at the point where testing out small incremental tweaks are taking a few minutes, not the ideal workflow. I'm hoping this is teething pains.
OK, so the great news is that the property-editors are working! 🌟 But I've hit a showstopper with the API Controllers. None of them want to load. I either get a 404 error, or this beautiful exception (for my tree dashboard)...
🚨🚨🚨 Full exception stack-trace here...
|
Beta Was this translation helpful? Give feedback.
-
...Day 6, a quick update... The Tree controller is now working! 🌟 On my test website, opened the Then after a full solution recompile, the Tree controller got picked up. Weird thing is that I checked the ...the journey continues... |
Beta Was this translation helpful? Give feedback.
-
...Day 7... (includes some things that I did on Day 6, but I ran out of time before writing up my notes) Having switched to using a Visual Studio solution for the test website and adding the project reference for Contentment's Having gone through the Contentment codebase, updated the various namespaces, successfully compiled, etc. Next it was time to go through all the features to see if they still worked. First I created a DataType for each of the main property-editors. Found a few errors, related to the view paths - inject a few Next I went through all of the Data Sources and List Editors for the Data List property-editor. Again a bunch of view path errors, whacked in more With the XML data-source, I noticed that Umbraco's Found a bug with the XML data-source too. I'm using Refactored the FileSystem data-source, as there was subtle changes to Umbraco's SQL data-source, I'm ended up commenting out the SQLCE specific code, as I don't want to have a dependency on a SQLCE NuGet. I tried looking through Umbraco source-code to see if there a was an agnostic approach I could take, but I got lost in the code. I've commented out the code for now. Will review later. This afternoon, I've been looking at adding configuration settings - initially for disabling the Telemetry feature. I wasn't sure how to go about doing this, then remembered that @warrenbuckley has a YouTube video about it, so watched that - thank you Warren! 🌟 ref: "Configuration & Options in Umbraco package for .NETCore"
I've got the basis of an injectable Next up, (well some time this week), I'll add all the DataTypes to DocumentTypes, and see how the content editing experience is. My expectation is that it'll work the same as v8 (from an AngularJS perspective). After that, it'll be frontend rendering + ModelsBuilder. ...the journey continues... |
Beta Was this translation helpful? Give feedback.
-
... tiny Day 8 update ... (not really a day, as I only had an hour to spare this afternoon ... gotta pay my mortgage, ya know 😉😆 ) Started adding the DataTypes to my DocumentType... and, gah, hit a snag! 😣 I can work around this for the time being - by setting an absolute ...the journey continues... |
Beta Was this translation helpful? Give feedback.
-
... Small update for Day 9 ... (I'm not sure whether I should be giving these updates day numbers anymore. It's pretty much when I can grab an hour or two at the moment. Umbraco v9 Beta 2 is out today! 🎉🎉 I had a quick look to see what the Changes between beta 1 and beta 2 were. Looked fine, didn't look anything major. Upgraded the "Umbraco.Cms" NuGet packages in my Visual Studio solution - for both Contentment and my test website. All fine. Then...
Hmmm, what is this? 🤔 I scratched my head, re-read the "Changes between beta 1 and beta 2" summary again. No mention of So next place I think is to dig through all the commits between "release-9.0.0-beta001" and "release-9.0.0-beta002" to see where Yup, time to roll your sleeves up, and get digging (in commits). I soon find out that I update my code, all compiled, let's move on. 🌟 Well, before I do, this change niggled me a bit. I re-read the "Changes between beta 1 and beta 2" summary again and it wasn't immediately obvious to me that "All notifications moved to the same namespace to make them easily discoverable" affected the Of course, I'm not expecting all 300+ file changes needed to be listed, but to me, in an Umbraco context, the word notifications is not something I'd cognitively associate with the old .NET Event Handlers. It's now an overloaded term... in an Umbraco context it could either mean:
Of course, as the saying goes... naming things is hard. Apologies that this became a bit of a ranty update. I'm trying to be honest and document my package migration journey, warts and all. Still lots of love and kudos to all involved. ✌️❤️🕊️ ...the journey continues... |
Beta Was this translation helpful? Give feedback.
-
...quick Day 10 update... All the property-editors are working! 🌟 There are a few minor snags, but (currently) no other showstoppers. 😄 I got the Content Blocks preview feature working. Spent a fair amount of time figuring out how to render a partial-view to a Found a small snag with Content Blocks' Content Template (Blueprint) feature, I got an error for the Umbraco API endpoint. There are a few other snags that I'd like to resolve before releasing an alpha version. Tried out the frontend parts. I could see from the contents of First I foolishly set the "models.generated.cs" file to Compile in Visual Studio - mistake! I got screamed at about duplicate Then I tried configuring a different ModelsBuilder mode, here's my config...
This now puts the generated C# classes into the "~/PublishedModels" folder, which can now be compiled. Intellisense works! 🌟 ...the journey continues... |
Beta Was this translation helpful? Give feedback.
-
Here's my (current) snag list. So far, they're all related to Data List - Data Sources... SQL data-sourceSQLCE support. I've had to comment out the SQLCE parts, as I'm unsure how to tackle it. The issue is that SQLCE support wont come natively with Umbraco for .NET Core, it's available as an extra (NuGet) dependency. So if I want to include it, that would add the dependency to Contentment - which isn't something I want. Ideally, I'd like the SQL data-source code to be generic, agnostic to the database provider - enter a SQL query, select a connection string, job done. Of course, there is always more code under the hood. I've had a look at how Umbraco core handles this, but I got a bit lost (again). If anyone has any bright ideas? 💡 I'm all ears. XML data-sourceCalling The strange thing is that if I do the same with the JSON data-source, a HTTPS URL is fine. The difference is that I'm using the I'm only using the Umbraco Members data-sourceThe call to My workaround is to call |
Beta Was this translation helpful? Give feedback.
-
Upgraded the NuGet dependencies on Contentment, there were various API breaking-changes - mostly related to Dependency Inject - but I'd expected this, so no big surprises. If you're curious about the types of changes, see commit: c9013ad. I'm not sure when to release an alpha of Contentment v3.0, as I'm unsure how many v9 beta releases there will be, and I don't want the pressure of immediately patching up any breaking-changes whilst still in beta. 🤔💭 ... rejsen fortsætter ... |
Beta Was this translation helpful? Give feedback.
-
Upgraded the NuGet dependencies. No breaking-changes! (I'm happy to be wrong about the betas) 😆 I made a change to how the CSS/JS assets are registered, see commit: 8c23c87. |
Beta Was this translation helpful? Give feedback.
-
With Umbraco 9 RC due out tomorrow, I've been working hard to get Contentment v3.0 (alpha001) ready for a pre-release on NuGet. In the Git repo, I've swapped the active branch to be ...I'll update again tomorrow! |
Beta Was this translation helpful? Give feedback.
-
Umbraco 9 RC is out ...and... Contentment v3.0.0-alpha001 has been released! In terms of journalising today's efforts... I hit a snag with the Umbraco 9 RC upgrade, I suspect it was to do with using SQLCE, I chatted with @warrenbuckley about it, but I wanted to crack on with my release. The rest of my effort has been hours of faffing around with my build scripts (see commit 833ca9f) - error Congratulations to @bergmania and the rest of the Unicore Team on today's v9 milestone release! #h5yr 👏👏👏 |
Beta Was this translation helpful? Give feedback.
-
The Umbraco 9.0.0-rc002 release had a few of breaking-changes, that @arknu quickly picked up on and sent me the fixes in #127 - I'm very grateful. Unfortunately, due to heavy workload commitments, I haven't had much free time to focus on Contentment releases, so PR #127 has been sat in my inbox for the past 20 days. Staring at me, the guilt slowly building. 😬 After seeing @JasonElkin's issue #130 last night, I thought I best get a patch release out. |
Beta Was this translation helpful? Give feedback.
-
Epilogue I never got around to writing about the last chapter of my Contentment for Umbraco 9 journey. I took a massive U-turn after chatting with other package developers (okay, Matt, Kevin and Marc) about ongoing support for both Umbraco v8 and v9. I decided to try out a multi-targeting approach to support both .NET 4.7.2 (Umbraco v8) and .NET 5 (Umbraco v9). I did talk a little bit about this in the release notes for v3.0.0-beta001 and v3.0.0. The good news is that this approach should work better me in supporting future feature requests with Umbraco v8. Originally I'd discarded continuing with v8, but after conversations that felt that I was dismissive and short-sighted. Which didn't fit my friendly nature, so I'm happy to have corrected course. ☘️ One thing that I wanted to flag in this last part is the Git branches. Throughout this journal, I've linked to the Thanks again to everyone who's been involved with the development of Contentment v3.0, it's been a journey! ✌️❤️🕊️ |
Beta Was this translation helpful? Give feedback.
-
Contentment for Umbraco 9
An Unexpected Journey
With the release of Umbraco 9 Beta (001), it is prime time for me to explore migrating current Contentment (for Umbraco 8) over to .NET 5, (TAFKA .NET Core).
Having never looked at .NET Core before, I have very little idea how this migration will pan out, so thought it worth documenting my journey. Wish me luck! ☘️🤞
Beta Was this translation helpful? Give feedback.
All reactions