简体   繁体   English

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

[英]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.configPackageReference

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 CoreNet 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 项目。

3) contact with the author on this link . 3)通过此链接与作者联系。

暂无
暂无

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

相关问题 使用.Net Core时,为安装的Nuget软件包定位的程序集在哪里? - Where are the Assemblies Located for Installed Nuget Packages When Using .Net Core? .Net Core 1.1.0 NuGet包无法在Visual Studio Mac中安装 - .Net Core 1.1.0 NuGet packages fail to install in Visual Studio Mac 如何将 TypeScript 定义添加到 .NET Core Nuget 包 - How to add TypeScript Definitions to .NET Core Nuget Packages VS模板没有安装Nuget包 - VS Template not installing Nuget Packages Visual Studio 2017仅具有适用于.NET Core 2.x的脱机Nuget包。如何获得在线套餐? - Visual Studio 2017 only has offline Nuget Packages for .NET Core 2.x. How to get online packages? 通过 Nuget 安装包 - “中央目录损坏” - Installing Packages through Nuget - "Central Directory corrupt" 如何将更新版本的 NuGet 包用于 .NET Core 3.1 中的依赖包? - How to use a more recent version of a NuGet package for dependent packages in .NET Core 3.1? 如何通过 NuGet 包共享源代码以用于 .NET Core 项目 - How to share source code via NuGet packages for use in .NET Core projects 为什么 NuGet 包中的内容文件作为链接添加到 .NET 核心项目中,您如何防止这种情况发生? - Why are content files from NuGet packages added as links in .NET Core projects and how can you prevent that? 在.net核心应用程序中通过nuget安装jquery ui后无法找到文件 - Can't find files after installing jquery ui via nuget in .net core application
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM