Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
342 views
in Technique[技术] by (71.8m points)

c# - Razor Core installing jquery.unobtrusive.ajax missing js files

I know i must be missing something incredibly obvious, but where are the js files? I install the package via nuget, but when i check for the js files to include them in my page, i cannot find them anywhere.

What do i do?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Over the years getting web front end resource (html, css, js) though NuGet has fallen out of favour. I expect it's largely due to lack of flexibility (the developer using the package can't decide where the files go, the package author does). I get the sense that large numbers of ASP.NET developers moved to using the same tools that non-.NET developers use for these files, which primarily is npm. You can see this with ASP.NET Core's angular and react templates using npm by default. The webapp and mvc templates now just ship some version of bootstrap and jquery in their template with no tooling support to update them, just a comment saying:

/* Please see documentation at https://docs.microsoft.com/aspnet/core/client-side/bundling-and-minification for details on configuring this project to bundle and minify static web assets. */

Since using npm's ecosystem is non-trivial (not saying it's hard, just non-trivial), the ASP.NET team created a simple library manager called LibMan.

So, I suggest either using LibMan to get jquery and whatever other front-end resources you want, or go down as far down the npm/webpack rabbit-hole as you like, you can make it as simple or complex as you like depending on what features you want. Or just download the file from jquery's website and copy it into your repo.

The reason that the NuGet package doesn't work for you is because the package contains only a content folder, but NuGet's docs on migrating from packages.config to packagereference specifically points out that "content" assets are no longer available. Package authors can use contentFiles to make their packages compatible with projects using PackageReference, but there's nothing a package consumer can do about it.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...