In asp.net mvc 5 I used to use the ClientDependency nuget package (https://www.nuget.org/packages/ClientDependency) to mange client dependencies like css and js files. You would put e.g. @Html.RequiresJs("jquery-1.8.1.min.js", "Scripts", 1); into your view, and it would get rendered in the web page. Now this ClientDependency project seems to be abandoned and not updated to .net 6.0 (https://github.com/Shazwazza/ClientDependency/tree/master). So my question is: what is currently the best way to manage your js and css dependencies? After a bit of googling I get the impression that not many people have been using this kind of technique to manage dependencies.
I learned today that the way to do this is using sections, it's pretty simple, here's an example, in your view you add for example a stylesheets section.
@section stylesheets {
<link rel="stylesheet" href="~/css/test.css" />
}
And in the shared layout you put a RenderSectionAsync like this:
@await RenderSectionAsync("stylesheets", required: false)
The only thing missing from the ClientDependency package is the potential dependency ordering (and perhaps handling duplicates), but this works well enough for now. Thanks everybody for their suggestions.