DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports Events Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
Zones
Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones AWS Cloud
by AWS Developer Relations
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones
AWS Cloud
by AWS Developer Relations
  1. DZone
  2. Coding
  3. Frameworks
  4. Installing Client-Side Libraries in ASP.NET Core

Installing Client-Side Libraries in ASP.NET Core

Microsoft products have been famously difficult to work with at times. One dev offers a solution to the round-about way of using client-side libraries in ASP.NET Core.

Paul Michaels user avatar by
Paul Michaels
·
Oct. 17, 18 · Tutorial
Like (4)
Save
Tweet
Share
30.77K Views

Join the DZone community and get the full member experience.

Join For Free

As a relative newcomer to the web front-end, one thing that always surprised me was how many moving parts you need to get something running. This is probably true elsewhere (i.e. in backend development and desktop development) but we just do a better job of hiding it. In the past, people writing web-pages have always had an uneasy relationship with Microsoft. Maybe it started in the late '90s when, in order to win the battle of the browsers with Netscape, Microsoft started giving its product away. Since then, IE has become more and more bloated, as it had to support 10 years worth of old technology, and people have had to ensure it still worked on IE 6 and 7.

But now things are different, Microsoft is a rebranded company and nobody hates them anymore... and when you create a brand new ASP.NET Core 2.1 project, you can use npm to install client-side packages, use them in your web page, and it all just works — end of the post.

Except that hasn't happened. In fact, the client-side package management for the web seems (to me) to be in a bit of a mess — especially where Microsoft is concerned.

Create a brand new ASP.NET Core 2.1 MVC project from the template and it comes with jQuery, supplied by Bower; except Microsoft isn't continuing support for Bower anymore.

So, use NuGet to install your package?

Nope, not on .NET Core!

So, use npm, that's still supported, right?

Yep. Here's the ASP.NET Signal R client-side package installed using npm:

Okay, so it puts it in 'node_modules' — I can reference the library directly from there, right?

Nope, it needs to be in wwwroot\lib.

Errr, so I copy it across manually?

You can. Although that's kind of the problem that package managers were invented to solve.

I can create a Gulp task to take the files out of the downloaded directory and place them into the lib directory!

Yes, yes you can. Although now you have a Gulp task, and an npm restore, all so that you can include one or two files in your project. This all just seems too hard!

Introducing LibMan. It isn't a Package Manager; but it might just be the correct answer to the question: "Why the hell is this whole thing so difficult. I only want one file!"

Here is the context menu for the lib folder after v15.8 (this has been available in preview for a while):

That gives you the following dialog:

This is amazing, I can pick the library that I want, and where I want it to go! I can also select specific files that I want — this almost feels like a sensible way to manage client-side packages. Click install and bang:

You can see what it's done by either selecting "Manage Client Side Packages..." from the solution context menu:

Alternatively, you can just have a look at the libman.json file (they both do the same thing as of 15.8.7, which makes me wonder whether "Manage Client Side Packages..." will do something different one day — the ellipses kind of give it away).

There's a CLI for it (which seemed to balk a bit when I tried to install it via NuGet), and you can use this as a replacement for Gulp to copy files around, by just selecting "File System" as the source (although this sort of solves that problem further down the tree).

https://docs.microsoft.com/en-us/aspnet/core/client-side/bower?view=aspnetcore-2.1

https://blogs.msdn.microsoft.com/webdev/2018/08/22/libman-cli-

released/https://blogs.msdn.microsoft.com/webdev/2018/08/31/library-manager-release-in-15-8/

ASP.NET ASP.NET Core Library

Published at DZone with permission of Paul Michaels, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

Popular on DZone

  • Authenticate With OpenID Connect and Apache APISIX
  • gRPC on the Client Side
  • Top 10 Best Practices for Web Application Testing
  • Important Data Structures and Algorithms for Data Engineers

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com
  • +1 (919) 678-0300

Let's be friends: