rebus-org / Rebus.ServiceProvider

:bus: Microsoft Extensions Dependency Injection container adapter for Rebus
https://mookid.dk/category/rebus
Other
67 stars 34 forks source link

Add support for .NET 9 #95

Closed ronaldbarendse closed 1 week ago

ronaldbarendse commented 1 week ago

With .NET 9 just released on November 12th, I'm trying to upgrade our product to use the latest .NET SDK and packages, but Rebus.ServiceProvider (and Rebus.Microsoft.Extensions.Logging) have upper version limits preventing this:

With the project using <TargetFramework>net9.0</TargetFramework> and having other dependencies that require the Microsoft packages with >= 9.0.0, the build fails with the following errors:

error NU1107:  Umbraco.Deploy.Cloud -> Rebus.ServiceProvider 10.2.0 -> Microsoft.Extensions.DependencyInjection (>= 8.0.0 && < 9.0.0).
error NU1107:  Umbraco.Deploy.Cloud -> Rebus.Microsoft.Extensions.Logging 5.0.0 -> microsoft.extensions.logging.abstractions (>= 6.0.0 && < 9.0.0).

A (temporary) workaround is to take explicit top-level dependencies on the version 9.0.0 packages:

<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="9.0.0" />
<PackageReference Include="Microsoft.Extensions.Hosting.Abstractions" Version="9.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="9.0.0" />

But this still causes a warning to be thrown during build (although everything seems to otherwise work fine):

warning NU1608: Detected package version outside of dependency constraint: Rebus.Microsoft.Extensions.Logging 5.0.0 requires microsoft.extensions.logging.abstractions (>= 6.0.0 && < 9.0.0) but version Microsoft.Extensions.Logging.Abstractions 9.0.0 was resolved.
warning NU1608: Detected package version outside of dependency constraint: Rebus.ServiceProvider 10.2.0 requires Microsoft.Extensions.DependencyInjection (>= 8.0.0 && < 9.0.0) but version Microsoft.Extensions.DependencyInjection 9.0.0 was resolved.
warning NU1608: Detected package version outside of dependency constraint: Rebus.ServiceProvider 10.2.0 requires Microsoft.Extensions.Hosting.Abstractions (>= 6.0.0 && < 9.0.0) but version Microsoft.Extensions.Hosting.Abstractions 9.0.0 was resolved.
warning NU1608: Detected package version outside of dependency constraint: Rebus.ServiceProvider 10.2.0 requires Microsoft.Extensions.Logging.Abstractions (>= 6.0.0 && < 9.0.0) but version Microsoft.Extensions.Logging.Abstractions 9.0.0 was resolved.
ronaldbarendse commented 1 week ago

@mookid8000 I don't want to pressure you, but it would be really great if the fixes could be released ASAP 😅 We're releasing version 15 of Umbraco CMS and all add-on products tomorrow (Thursday 14th) and they target .NET 9. The linked PRs only change the dependency upper version limits, so no other code has changed and it can be released as a quick patch...

The reason why this only surfaced when the final .NET 9 versions were released is due to how NuGet version ranges are compared: >= 6.0.0 && < 9.0.0 still allows prerelease versions like 9.0.0-rc2, as they are considered a 'lower' version than 9.0.0 (and therefore still satisfy the version range)...

mookid8000 commented 1 week ago

@ronaldbarendse Rebus.ServiceProvider 10.3.0 is on NuGet.org now 🙂 thanks for pushing it a little bit 😅

ronaldbarendse commented 1 week ago

Awesome work, thanks! Don't forget about the Rebus.Microsoft.Extensions.Logging as well, because that has a similar dependency upper version limit :wink: