Maintenance Considerations
When migrating a package to V9, an important decision to make is how to maintain the code moving forward when it comes to supporting multiple Umbraco versions - in addition to the actual code changes necessary. Even when V9 is fully released, there will be many Umbraco installations running on V8 for quite some time, so any package already supporting this version will need to be maintained with bug fixes, and, for many, new features too.
There are a few ways to tackle this, broadly trading off some complexity in the initial and ongoing development, versus ease of maintaining parity between versions and releasing. A non-exhaustive set of options being:
- Start a separate V9 project, in a new code repository. This might be attractive if you consider the V8 package broadly “done” and/or want to make significant changes or refactorings to the new version for V9.
- Maintain a single repository but have different branches for V8 and V9 versions, using merging to ensure features and bug fixes made in one are applied to the other. This is the approach HQ have adopted with their commercial packages.
- Implement a single branch with multi-targeted code, using compiler directives and project file conditions to ensure a single code-base can be compiled to both .NET Framework (Umbraco 8) and .NET 5 (Umbraco 9).
For UI examples, we decided to go with the latter approach. That’s partly so we could see this in action, and help others see if it’s an appropriate option for them. Additionally, the project does seem to have some characteristics that make it a good candidate for this method: the amount of C# code compared to client-side code is small, and it’s only the former that we need to be concerned about for multi-targeting.
Even for larger packages though, we’d still consider this a viable option. There is additional complexity at the outset and to an extent in ongoing development, but in practice, it’s mostly the C# code that has dependency on Umbraco APIs that requires the multi-targeting directives in the code. Although these APIs haven’t been altered significantly, there are now different namespaces and constructors to consider, and some names, signatures and access modifiers have changed.
If you have other, non-Umbraco dependent code for business logic or other infrastructure, it’s quite possible these will compile to both .NET versions with little difference, or could even be implemented as .NET Standard class libraries working across both .NET Framework and .NET 5 without need for multi-targeting.