问题描述
我从这个站点安装了 .net 核心.使用它会导致一些相关的包管理问题:
I installed .net core from this site. Playing with it led to a number of related package management questions:
dotnet restore
命令继续安装".net 核心 NuGet 包.这些软件包安装"在哪里?未创建新文件夹.- hello world"最小示例的
dotnet restore
需要大约一百个 NuGet 包,其中 99% 可能与hello world"应用程序无关.诚然,.net 原生构建将删除所有不需要的东西 - 但我预计restore
也只会抓取很少的东西(三个或四个包,而不是一百个).为什么会出现这种行为? - 我创建了第二个hello world"项目并再次运行
dotnet restore
.这次根本没有安装任何软件包.似乎第一次安装的所有软件包都进入了某个全球位置以进行共享.我认为.Net Core 不是这样工作的.我认为 .Net Core 项目将所有依赖项都保存在本地.我所针对的唯一框架是dnxcore50
.为什么会有这种行为? - 我想卸载"所有这些全局包,然后再试一次(仅用于学习目的).那怎么可能实现?请记住,如问题 1 所述,我不知道所有这些文件的安装位置.
- 几乎所有通过
restore
命令安装的软件包都被列为测试版.奇怪的.我认为 .Net Core 处于 RC1 中,而不是 beta 版.对此感到困惑.为什么会出现这种行为?
- The
dotnet restore
command proceeded to "install" .net core NuGet packages. Where were those packages "installed"? A new folder was not created. - The
dotnet restore
for the "hello world" minimal example required about a hundred NuGet packages, where 99% were presumably irrelevant to the "hello world" app. Granted, a .net native build will remove all that is not needed - but I expected that therestore
also would have grabbed very little (three or four packages, not a hundred). Why this behavior? - I created a second "hello world" project and again ran
dotnet restore
. This time no packages were installed at all. It seems all the packages installed the first time-around went into some global location to be shared. I thought .Net Core didn't work that way. I thought .Net Core projects kept all their dependencies locally. The only framework I targeted wasdnxcore50
. Why this behavior? - I would like to "uninstall" all these global packages, and try again (just for learning purposes). How might that be accomplished? Remember, as stated in question #1, I don't know where all those files were installed.
- Almost all of the packages installed via the
restore
command were listed as beta. Odd. I thought .Net Core was in RC1, not beta. Confused by this. Why this behavior?
我也很好奇哪些文档可以/会向我解释这一切.我尝试用谷歌搜索这些问题,但什么也没找到(也许只是可怕的 google-fu?).
I'm also curious of what documentation could/would have explained all this to me. I tried googling for each of these questions, and found nothing (perhaps just horrible google-fu?).
推荐答案
更新:
- nuget 包安装在全局位置.默认情况下,它曾经是 ..Users[YourUserFolder].dnxpackages 但它似乎已更改为 ..Users[YourUserFolder].nugetpackages
在 NuGet 3+ 中,您可以使用 NuGet CLI 的以下命令来获取 global-packages 文件夹位置
In NuGet 3+, you can use the NuGet CLI's following command to get the global-packages folder location
nuget locals global-packages -list
查看以下链接了解有关 NuGet 的更多详细信息
Check out following links for more details about NuGet
http://blog.nuget.org/20151008/NuGet-3-What-and-Why.html
https://docs.nuget.org/ndocs/consume-packages/配置-nuget-behavior
https://docs.nuget.org/ndocs/tools/nuget.exe-cli-reference#locals
默认的 ASP.Net 模板有很多包.由于您第一次尝试,它尝试获取所有这 100 个包
The default ASP.Net template has so many packages. Since you tried first time, it tried get all those 100s of packages
你已经在你的 nuget 全局位置有这些包,它跳过了恢复.
You already had those packages in your nuget global locations, it skipped the restore.
删除packages文件夹下的所有内容(位置在1中)
Delete all contents under packages folder (location indicated in 1)
那里有一些测试版包.您可以转到 project.json 文件(在 web 根目录下可用)并使用依赖项部分.
Some of the beta packages are there. You can go to project.json file (available under the web root) and play with the dependencies section.
这篇关于.Net Core 和 NuGet的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!