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
Please enter at least three characters to search
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

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
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

Last call! Secure your stack and shape the future! Help dev teams across the globe navigate their software supply chain security challenges.

Modernize your data layer. Learn how to design cloud-native database architectures to meet the evolving demands of AI and GenAI workloads.

Releasing software shouldn't be stressful or risky. Learn how to leverage progressive delivery techniques to ensure safer deployments.

Avoid machine learning mistakes and boost model performance! Discover key ML patterns, anti-patterns, data strategies, and more.

Related

  • GDPR Compliance With .NET: Securing Data the Right Way
  • How to Enhance the Performance of .NET Core Applications for Large Responses
  • Developing Minimal APIs Quickly With Open Source ASP.NET Core
  • Revolutionizing Content Management

Trending

  • Medallion Architecture: Efficient Batch and Stream Processing Data Pipelines With Azure Databricks and Delta Lake
  • How AI Agents Are Transforming Enterprise Automation Architecture
  • 5 Subtle Indicators Your Development Environment Is Under Siege
  • Build Your First AI Model in Python: A Beginner's Guide (1 of 3)
  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.

By 
Paul Michaels user avatar
Paul Michaels
·
Oct. 17, 18 · Tutorial
Likes (4)
Comment
Save
Tweet
Share
31.7K 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.

Related

  • GDPR Compliance With .NET: Securing Data the Right Way
  • How to Enhance the Performance of .NET Core Applications for Large Responses
  • Developing Minimal APIs Quickly With Open Source ASP.NET Core
  • Revolutionizing Content Management

Partner Resources

×

Comments
Oops! Something Went Wrong

The likes didn't load as expected. Please refresh the page and try again.

ABOUT US

  • About DZone
  • Support and feedback
  • Community research
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

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

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 100
  • Nashville, TN 37211
  • support@dzone.com

Let's be friends:

Likes
There are no likes...yet! 👀
Be the first to like this post!
It looks like you're not logged in.
Sign in to see who liked this post!