繁体   English   中英

Nuget 软件包未在 .net 核心应用程序中安装任何内容

[英]Nuget Packages not installing anything in .net core app

我正在尝试通过 Nuget 在 .net 核心应用程序中安装 knockoutjs 和 typescript。

它显示在 Packages 中,但没有像以前在 asp.net 中那样在脚本文件夹中安装任何东西。

在此处输入图像描述

我错过了什么?

TL;DR ASP.NET 核心不再以这种方式工作(将 javascript/css 内容复制到项目中的包)。 您需要调整您的工作流程。

.NET 核心项目仅适用于 SDK 风格的项目,SDK 风格的项目仅使用 NuGet 的PackageReference ,而不是packages.config packages.config迁移到PackageReference的文档列出了一个package 兼容性问题,因为它不支持content文件夹,这就是在packages.config中将这些资产复制到 package 安装的项目中的方式。

I can't find a doc listing recommendations for ASP.NET Core apps, but my understanding is you can either use LibMan , or use NPM, which is in line with basically the rest of the web development industry outside of .NET has been doing. If you use the new project templates to create a new ASP.NET Core Angular or ASP.NET Core React app, you'll see they create a ClientApp folder that uses npm and all the official react/angular CLI tools. MVC 模板有 jQuery 和引导程序的副本,但没有明确的方式来更新它们。

可能有些不同步,从解决方案中删除包文件夹并再次恢复包。 它将解决问题。 还要检查 output window,它将显示错误列表。

它显示在 Packages 中,但没有像以前在 asp.net 中那样在脚本文件夹中安装任何东西。

首先,我同意zivkan 它是PackageReference Nuget 管理格式的一个特点。

VS 有两种格式来管理 nuget 包: Packages.configPackageReference

由于新的 sdk 格式项目( Net CoreNet Standard )只使用PackageReference来管理 nuget 包,它与packages.config ZEFE90A8E604A7C840E88ZD03A67F6B7D 格式管理所反映的效果会有很大的不同。

当您将 nuget 包中的内容文件与PackageReference一起使用时,它将丢失 Scripts 文件夹中的文件。

正如本文档所说,它有这样的兼容性问题。

在此处输入图像描述

Actually , you can enter C:\Users\xxxx\.nuget\packages\knockoutjs\3.5.1 and find there is a folder called Content , Nuget will copy the content of that folder into your project when you install this nuget package.

但是Content文件夹可以通过Packages.config格式识别,据我所知, PackageReference中使用ContentFiles文件夹将内容添加到您的项目中。 因此,在您的情况下, nuget package 应该同时包含ContentFiles文件夹。 这个官方文档

但是knockoutjs nuget package 没有 contentfiles 文件夹。 这就是为什么带有packages.config的网络框架项目有内容文件,而新的 sdk 项目没有它。

And this behavior change can only be effective when you create the nuget package, so you ca n't make any kind of change, you can only contact the author of the package to make this modification, and let him add this function as soon as可应用于新的 SDK 格式项目。

建议

所以现在,你可以试试这些:

1)您可以通过添加现有项目手动将C:\Users\xxxx\.nuget\packages\knockoutjs\xxxx\Content中的内容文件添加到项目中。

2)回滚以使用带有packages.config的 Net Framework 项目。

3)通过此链接与作者联系。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM