Now Visual Studio 2019 has changed the way NuGet saves libraries, and instead of each project, they are stored in C:\Users\[Username]\.nuget\packages
.
That's welcome, but how do I write the path to the .css and .js files in the *.cshtml file of View in .net MVC?
The auto-generated Views/Shared/_Layout.cshtml
shows the following, but the actual location is .nuget\packages\bootstrap\4.5.0\content\Content
and I don't know why I should write "~lib/[lib/[library name]/dist"
.
<link rel="stylesheet" href="~/lib/bootstrap/dist/css/bootstrap.min.css"/>
<script src="~/lib/jquery/dist/jquery.min.js"></script>
<script src="~/lib/bootstrap/dist/js/bootstrap.bundle.min.js">/script>
Please teach me.
html visual-studio nuget
I actually did it and solved it. First of all, in Visual Studio 2019, NuGet's javascript-related libraries and the libraries that View's .cshtml files refer to are different.
In Visual Studio's solution explorer, there is a directory called wwwroot, where the folder css,js,lib is the folder referenced by .cshtml, so put jquery.js, etc. in the js or lib folder here.
"The description ""~/lib/jquery/dist/jquery.min.js"" I wrote in the question was a description of the file originating from this wwwroot."
To put the library here, right-click on wwwroot and it's a relatively simple function, although it's somewhat automatic with the "add/client side library" feature in the menu.It seems to be called libman.
Summary -
In Visual Studio 2019, managing the client library is separate from managing the nuget library, and there is no point in installing the only library on the client side with nuget.
Client-side libraries should be managed almost manually. (There is a simple tool called libman.)
References from the .csmhtl page start with wwwroot and write "~/css/..."
© 2024 OneMinuteCode. All rights reserved.