Reputation: 711
I have an ASP.Net (.Net Framework) MVC web application in Visual Studio 2017 that is comprised mainly of JavaScript. I have used NuGet to install a package (specifically the marker-animate-unobtrusive
package.) The documentation goes on to say that i should include the JavaScript in my HTML pages but upon examining exactly what NuGet did I'm not sure how to proceed.
I have checked my packages.config
file and have found a reference to the package, which I have also been able to find in the packages
folder in the root of the solution. But these references indicate a TypeScript file - should I just be including that in my HTML?
And how would I do that, if that were the case? Should I route back to the packages folder? That seems like a bad idea, since that's not even included in my project. How can I dynamically link to what I've installed?
I am just getting to grips with Visual Studio and don't understand what it's doing some of the time, so any pointers would be helpful. In a broader sense, the two questions I'm mainly asking are:
What is NuGet doing exactly when you install a package?
How can these packages be accessed in the context of my web pages and JavaScript?
Upvotes: 0
Views: 239
Reputation: 4430
What does NuGet do when you install a package? In this specific case it is extracting the js files to your Scripts folder and if any css is needed then it exacts the CSS files or in some cases folders to your Content folder of your solution.
If you want the js to be included on just certain pages and not all then at the bottom of the target pages (Views > Controller > Whatever.cshtml) you put the following lines:
@section css {
<link href="~/Content/Your installedCSS.css" rel="stylesheet" class="skins" type="text/css">
}
@section scripts{
<script src="~/Scripts/YourInstalledScript.js"></script>
}
What this is telling it to do is to find where you have the section "scripts" and "css" defined in your site layout page (Views > Shared > _Layout) and place the included files there.
Look for lines:
@RenderSection("css", required: false)
@RenderSection("scripts", required: false)
Upvotes: 1