[英]Nuget Packages not installing anything in .net core app
I am trying to install knockoutjs and typescript in a .net core app via Nuget.我正在尝试通过 Nuget 在 .net 核心应用程序中安装 knockoutjs 和 typescript。
It shows in Packages but doesn't install anything in a scripts folder as has previously in asp.net.它显示在 Packages 中,但没有像以前在 asp.net 中那样在脚本文件夹中安装任何东西。
What am I missing?我错过了什么?
TL;DR ASP.NET Core no longer works in that way (packages copying javascript/css content into your project). TL;DR ASP.NET 核心不再以这种方式工作(将 javascript/css 内容复制到项目中的包)。 You need to adapt your workflow.
您需要调整您的工作流程。
.NET Core projects only work in SDK-style projects, and SDK style projects only use NuGet's PackageReference
, not packages.config
. .NET 核心项目仅适用于 SDK 风格的项目,SDK 风格的项目仅使用 NuGet 的
PackageReference
,而不是packages.config
。 The docs on migrating from packages.config
to PackageReference
list one package compatibility issue as not supporting the content
folder , which is how in packages.config
those assets are copied into your project on package install. 从
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. 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. 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. The MVC template has copies of jQuery and bootstrap, without an obvious way how to update them. MVC 模板有 jQuery 和引导程序的副本,但没有明确的方式来更新它们。
might be some unsync, remove the packages folder from the solution and restore the packages again.可能有些不同步,从解决方案中删除包文件夹并再次恢复包。 It will fix the issue.
它将解决问题。 Also check the output window, that will show the list of errors.
还要检查 output window,它将显示错误列表。
It shows in Packages but doesn't install anything in a scripts folder as has previously in asp.net.
它显示在 Packages 中,但没有像以前在 asp.net 中那样在脚本文件夹中安装任何东西。
First , I agree with zivkan .首先,我同意zivkan 。 It is a feature of PackageReference Nuget Management format .
它是PackageReference Nuget 管理格式的一个特点。
VS has two format to manage nuget packages: Packages.config and PackageReference . VS 有两种格式来管理 nuget 包: Packages.config和PackageReference 。
Since new sdk format projects( Net Core
and Net Standard
) only use PackageReference to manage nuget packages,it will be very different from the effect reflected by the packages.config package management format .由于新的 sdk 格式项目(
Net Core
和Net Standard
)只使用PackageReference来管理 nuget 包,它与packages.config ZEFE90A8E604A7C840E88ZD03A67F6B7D 格式管理所反映的效果会有很大的不同。
When you use Content files from the nuget packages with PackageReference , it will lose files from the Scripts folder.当您将 nuget 包中的内容文件与PackageReference一起使用时,它将丢失 Scripts 文件夹中的文件。
Just as this document said, it has such compatibility issues.正如本文档所说,它有这样的兼容性问题。
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. 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.
But Content folder can be recognized by Packages.config
format, and as far as I know, ContentFiles folder is used in PackageReference to add the content into your project.但是Content文件夹可以通过
Packages.config
格式识别,据我所知, PackageReference中使用ContentFiles文件夹将内容添加到您的项目中。 So in your situation, the nuget package should include ContentFiles folder at the same time.因此,在您的情况下, nuget package 应该同时包含ContentFiles文件夹。 See this official document .
见这个官方文档。
But the knockoutjs
nuget package does not have contentfiles folder.但是
knockoutjs
nuget package 没有 contentfiles 文件夹。 That is why net framework projects with packages.config
has the content files while new sdk projects does not have it.这就是为什么带有
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 possible to apply to the new SDK format project. 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 格式项目。
Suggestion建议
So So for now, you can try these:所以现在,你可以试试这些:
1) you can either manually Add the content file from C:\Users\xxxx\.nuget\packages\knockoutjs\xxxx\Content
to the project by Adding Existing Items . 1)您可以通过添加现有项目手动将
C:\Users\xxxx\.nuget\packages\knockoutjs\xxxx\Content
中的内容文件添加到项目中。
2) roll back to use Net Framework projects with packages.config
. 2)回滚以使用带有
packages.config
的 Net Framework 项目。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.