Dot Net Core 8

by samantha copeland on April 3, 2024

In the past few months at my day job I have spent a lot of time updating code to the latest LTS version of .Net, so I decided the .Net 6 incarnation of CarrotCakeCMS should get a similar treatment.

Look for the repos [ github | sourceforge ] being updated with .Net 8 focused changes in the next week.

In the meantime, if you want to do it yourself, it's pretty straightforward. This does require using Visual Studio 2022 build 17.8 or later (due to .Net 8 support).

In the solution, find and replace <TargetFramework>net6.0</TargetFramework> with <TargetFramework>net8.0</TargetFramework> generally this is in the csproj, but will also be found in publish profiles.

Use the nuget manager for the solution, update all Microsoft binary libraries to their latest .Net 8 versions (sometimes you may have to manually edit the csproj file as sometimes the prerequisite checks create a cyclic dependency reference), the one exception is for EntityFrameworkCore packages.

Your version of SQL Server will guide which version of EF to use. If you are using SQL 2014 or earlier, DO NOT update to EF 8, leave at the latest EF 7 version, SQL 2014 and earlier versions do not understand JSON, which is what EF 8 will try to use for some LINQ/SQL statement conversions. If you encounter the exception "SqlException: Incorrect syntax near the keyword 'WITH'. Incorrect syntax near the keyword 'with'. If this statement is a common table expression, an xmlnamespaces clause or a change tracking context clause, the previous statement must be terminated with a semicolon." that will be your clue to stay with EF 7 or upgrade to MSSQL 2016 or later.

Once you have it built, you will need to visit the admin page to perform a password recovery as the hashing algorithm for .Net 8 is different from .Net 6 so passwords will no longer match. Performing a reset will establish the new password with the new hashing algorithm.

I found that even if it runs fine in Visual Studio, the published version was missing a DLL once deployed. This was fixed by manually updating the csproj file for the System.Security.Cryptography.Pkcs package, it's a little strange as this was not a problem with .Net 6, but with the .Net 8 publish. This may be tied to the mail library, MimeKit, based on the Github bug and the listed dependencies, but this is also strange as the main GUI project references both MimeKit and MailKit directly.

Ultimately, I will be updating to EF 8, which will mean a new minimum version of MSSQL 2016 for CarrotCakeCMS on .Net Core, but the first few passes will still reflect the EF 7 version.