DavidAJohn / FotoStorioMicroservices

.NET application built using a microservice architecture with Docker containers. Includes a Blazor WebAssembly e-commerce store with Stripe Elements payment integration.
23 stars 4 forks source link

Update all projects to .NET 6 #2

Closed DavidAJohn closed 2 years ago

DavidAJohn commented 2 years ago

At the moment, the application consists of a mixture of .NET 5 and .NET 6 projects.

The Blazor client apps are .NET 6, but most of the backend services are still .NET 5.

It's not a huge problem, but it would be nice to have everything consist, especially as .NET 6 is the LTS release.

The first step would be updating the version numbers in the .csproj files and testing that each project still builds successfully.

DavidAJohn commented 2 years ago

As a test, I've updated the nuget packages and the Dockerfile in the Marketing Gateway to .NET 6. This also meant updating Ocelot to v18.0.

The project builds successfully. There don't appear to be any problems, but updating the store and admin gateways in the same way might expose any underlying issues with Ocelot 18 and the current configs,

Although it's not required, I may also switch it to use the simplified Program.cs-only implementation that is standard in new .NET 6 projects.

DavidAJohn commented 2 years ago

Switched the Marketing Gateway project to also use the .NET 6 Program-only model here: 459c09425f86abb3c730f1495bd3df5d953a0dc

After updating the nuget packages (from the previous commit here): 7041ebde557fba5127cd5023bf6bf89c707e6880 :

It's just a case of re-writing the Program.cs file, then adding the implict usings tag to the .csproj file and rebuilding. The rebuild generates the global usings file in the hidden 'obj' folder.

You can then also right-click the Program.cs using refs and choose 'Remove and Sort Usings'. It seems to remove the ones that are now in the generated global usings file. Neat.

DavidAJohn commented 2 years ago

Just as a reminder, I made the mistake of forgetting to add the previous contents of the Program.cs file back in after moving the Startup config stuff across. As detailed here: 9b2fa3df916c0302ad4f3d1d133aa8136abd5ab2

That of course included the crucial Ocelot json config file references.

DavidAJohn commented 2 years ago

Further progress on the .NET 6 updates:

The Admin Gateway has been updated: fba9e214a85c62ef0f6fd098ae6468ac3cdafd84

The Store Gateway has been updated: 082f8e70fb12f9064259d346fa3f26c03f09ae05

And the most complex of the updates so far, the Products Aggregator: 952ce268a0a7e096b236218c1f351599886f05e7

DavidAJohn commented 2 years ago

The Basket API has also now been updated to .NET 6 : 33e6405b76929ea2c8c634c6fd0b7b7a43896466

DavidAJohn commented 2 years ago

The Identity API has also been updated: 0b169267c16864cd043523b9467f026cfda1874d

DavidAJohn commented 2 years ago

The Inventory API has now been updated, as detailed in this commit: e83bc054314f18799819793d24353930b18d9823

This was a bit more of an issue because of some major breaking changes in the Npqsql library for PostgreSQL/EF, involving DateTime values with or without timezones.

For now, I've simply opted out of this by adding a line into the Program.cs file.

It may be worth revisiting this later, to fully understand the implications of the changes.

The upgrade guide can be found here.

DavidAJohn commented 2 years ago

The remaining .NET 5 projects have all now been updated to .NET 6, including:

Products API : a3e4d61cbfada1962477808d40e2de1e9b53c2d7

Ordering API : d7475ebc33c96eef60398d8ae63a7478f280eca8

EventBus class library : 739621846871fedaca7ab4f14030220e66a38129

DavidAJohn commented 2 years ago

All parts of the application have now been updated to .NET 6.