I know that SignalR is included out of the box for a net 7 web api project.
But if I create a class library and want to create my Hub
class there instead of the web project, which Nuget package should I use, now when Microsoft.AspNetCore.SignalR
is deprecated?
Someone asked the same question on learn.microsoft.com
The package Microsoft.AspNetCore.SignalR is deprecated. May I know the latest package for the same.I am panning to work with .Net 6.
One of the answers was:
if your project is a library where you want to use SignalR server functionality, you can add a framework reference to your project. As @Zhi Lv - MSFT mentioned, SignalR is now contained in the Microsoft.AspNetCore.App framework.
With a link to this article : https://learn.microsoft.com/en-us/aspnet/core/fundamentals/target-aspnetcore?view=aspnetcore-7.0&tabs=visual-studio
Which is stating, among other things :
With the release of .NET Core 3.0, many ASP.NET Core assemblies are no longer published to NuGet as packages. Instead, the assemblies are included in the Microsoft.AspNetCore.App shared framework, which is installed with the .NET Core SDK and runtime installers. For a list of packages no longer being published, see Remove obsolete package references.
As of .NET Core 3.0, projects using the Microsoft.NET.Sdk.Web MSBuild SDK implicitly reference the shared framework. Projects using the Microsoft.NET.Sdk or Microsoft.NET.Sdk.Razor SDK must reference ASP.NET Core to use ASP.NET Core APIs in the shared framework.
So the solution would be to add the following to your library's csproj:
<ItemGroup>
<FrameworkReference Include="Microsoft.AspNetCore.App" />
</ItemGroup>