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

查看:53
本文介绍了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 网格时遇到了同样的问题.至少在那里我可以破解脚本.

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(节点包管理器)来添加 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天全站免登陆