Search code examples
asp.net-coresignalrasp.net-core-2.2asp.net-core-signalr

SignalR: Cannot get js libraries in Visual Studio 2017 project


Trying to following this tutorial to get basic SignalR working: https://learn.microsoft.com/en-us/aspnet/core/tutorials/signalr?tabs=visual-studio&view=aspnetcore-2.2

I am using Visual Studio 15.9.7

the tutorial includes the instructions below, but when I follow them, the modal window disappears without any kind of message and I do not have the signalr javascript libraries anywhere. The lib/signalr folder isn't extracted into my application. Nothing.

I looked around to try and figure out where to download them manually. Nothing.

I tried running all the Package Console commands to try and get signalR. like this one: npm install @aspnet/signalr

Nothing.

Is there an easy and proven way to just get these js libraries?

In Solution Explorer, right-click the project, and select Add > Client-Side Library.

In the Add Client-Side Library dialog, for Provider select unpkg.

For Library, enter @aspnet/signalr@1, and select the latest version that isn't preview.

Add Client-Side Library dialog - select library

Select Choose specific files, expand the dist/browser folder, and select signalr.js and signalr.min.js.

Set Target Location to wwwroot/lib/signalr/, and select Install.

Add Client-Side Library dialog - select files and destination

LibMan creates a wwwroot/lib/signalr folder and copies the selected files to it.

Solution

  • Firstly, you can try to update your Visual Studio and check if it can help fix the issue.

    Besides, to add the SignalR client library to the project, we can also use LibMan Cli command.

    • Run the following command to install LibMan (if not installed it before)

      dotnet tool install -g Microsoft.Web.LibraryManager.Cli

    • Run the following command to get the SignalR client library

      libman install @aspnet/signalr -p unpkg -d wwwroot/lib/signalr --files dist/browser/signalr.js --files dist/browser/signalr.min.js