Nuget问题下载脚本 [英] Nuget Problems Downloading Scripts

查看:16
本文介绍了Nuget问题下载脚本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好的,这以前发生过,我不确定这是什么交易.

Ok, this has happened before, I'm not sure what the deal is.

我去安装这个 nuget 包-Microsoft.jQuery.Unobtrusive.Ajax

I go to install this nuget package- Microsoft.jQuery.Unobtrusive.Ajax

使用命令行和 GUI 都正确"地安装了软件包.但是我的项目中没有添加任何脚本?

the package is installed "correctly" both using the command line and the GUI. But there is no scripts added to my project?

我在使用 MVC6 Grid 时遇到了同样的问题.至少在那里我可以破解脚本.

I had the same problem with MVC6 Grid. At least there I could hack the scripts in.

我在 Microsoft 的 CDN 页面上找到了实际脚本,因此我可以解决这个问题……只是想知道我是否遗漏了什么.

I found the actual script on Microsoft's CDN page so I can work around this...just wondering if I'm missing something.

使用 Visual Studio 2017,如果有帮助,该项目是一个 Core 2.0 MVC 项目.谢谢.

Using Visual Studio 2017 and the Project is a Core 2.0 MVC project if that helps. Thanks.

推荐答案

使用命令行和 GUI 都正确"地安装了软件包.但是我的项目中没有添加任何脚本?

the package is installed "correctly" both using the command line and the GUI. But there is no scripts added to my project?

由于不鼓励将 NuGet 用于 css/javascript 库.您应该使用 Bowernpm (Node Package Manager) 添加 JavaScript 库,而不是使用 NuGet.较新的项目文件格式 PackageReferences 仅支持 NuGet 包内 contentFiles 目录中的文件.

Since the usage of NuGet for css/javascript libraries is discouraged. You should use Bower or the npm (Node Package Manager) to add the JavaScript libraries instead of using NuGet. The newer project file formats, PackageReferences, only supports files that are in a contentFiles directory inside the NuGet package.

要将包 Microsoft.jQuery.Unobtrusive.Ajax 用于 .net 核心项目,您需要选择 MVC 项目并将新文件添加到项目根目录.在模板管理器中(添加->新建项目...),搜索Bower 配置文件"或npm 配置文件".

To use the package Microsoft.jQuery.Unobtrusive.Ajax to the .net core project, you eed to select your MVC project and add a new file to the project root. While in the template manager (Add->New Item...), search for "Bower Configuration File" or "npm Configuration file".

然后编辑文件并添加你的依赖,即

Then edit the file and add your dependency, i.e.

package.json (npm) 或 bower.json:

package.json (npm) or bower.json:

  "dependencies": {
    "jquery-ajax-unobtrusive": "3.2.4"
  }

注意:对于 package.json (npm),一旦你保存,文件将被下载到名为node_modules"的目录中.仅此是不够的,因为需要的文件需要复制过来到 wwwroot 文件夹,在应用程序运行时可以访问它们.

Note: For package.json (npm), once you save, the file will be downloaded in a directory named "node_modules`. This alone won't be enough, as the required files need to be copied over to wwwroot folder, where they can be accessed when the application runs.

有关详细信息,请参阅 NPM、BOWER、NUGET、GULP – ASP.NET CORE 应用的四骑士.

For the detailed info, see NPM, BOWER, NUGET, GULP – The Four Horsemen of ASP.NET CORE Apps.

这篇关于Nuget问题下载脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆