aspnet / SignalR-samples

Samples for ASP.NET Core SignalR
753 stars 398 forks source link

Using SignalR Core in a standalone .NET application #108

Closed jgauffin closed 3 years ago

jgauffin commented 3 years ago

This is another perspective of https://github.com/dotnet/aspnetcore/issues/20768.

With the previous version of SignalR it was possible to create a host for SignalR without having to include the entire ASP.NET infrastructure. I that possible with the new version? i.e. limiting the amount of required packages, instead of having to install Microsoft.AspNetCore.All?

My use case is that we have 40 different microservices in which we use RabbitMQ/NServiceBus for communication fo commands and events. We are using WebSockets (the vanilla ones in .NET Core) for executing queries.All of our microservices are console based and currently running as window services (they are prepared for docker).

Let's do an comparison.

For legacy signalR, there is a succint documentation that shows step-by-step how to install SignalR as standalone. That would be easy to implement in our services. But why use that version when there is a newer one for .NET?

For SignalR Core, all documentation expects that you can use the WebSdk as SDK type in your csproj. That is not an option for us. From what I've discovered, the option is to install Microsoft.AspNetCore.All. However, when using .NET Core 3.0 or higher it's not possible to reference that meta-package in a console/sdk application. Instead, by googling you discover that you can use <FrameworkReference Include="Microsoft.AspNetCore.App" /> instead in your csproj.

When comparing the output (i.e. publish self-contained), there is a minimal amount of ASP.NET dlls included for the old version of signalR while the entire ASP.NET stack (including MVC etc) is included for SignalR Core.

The issue:

Is it possible to create a minimal SignalR host with ASP.NET Core? Like just using just the Microsoft.AspNetCore.Hosting, Microsoft.AspNetCore.Routing and Microsoft.AspNetCore.SignalR packages? I tried, but didn't manage to get everything fully working.

jgauffin commented 3 years ago

posted in the wrong repos

jgauffin commented 3 years ago

New location: https://github.com/dotnet/aspnetcore/issues/32422