What NuGet sources are used for restore?

拥有回忆 提交于 2020-07-09 19:06:49

问题


I'm doing a simple dotnet restoreon my mac. I'm using the (for now) latest dotnet CLI version 2.2.

Since you can have both a NuGet.Config file in your project folder and a machine-wide config, say:

  • ~/projects/helloworld/.NuGet/NuGet.Config

  • ~/.nuget/NuGet/NuGet.Config

Is there any way to ask dotnet restore like "hey, if if were to run you, what combination of NuGet sources would you actually use?"

As you might have guessed my problem is that i'm not really sure that all my defined sources are used.

(actually my problem is that running dotnet restore --interactivedoes not prompt me, which I would expect, so I assume NuGet is not even trying to fetch packages from my defined source)

Hope you guys can help me out.


回答1:


Use dotnet restore -v:n to make dotnet restore display information with "verbosity" level of "normal". This will show you a lot of information. Towards the end, you will get information like this:

     NuGet Config files used:
         /home/omajid/.nuget/NuGet/NuGet.Config

     Feeds used:
         https://api.nuget.org/v3/index.json

That shows which nuget config files and nuget feeds were used.

(Unfortunately, there doesn't seem to be a option to say "just show me, but don't do a restore".)




回答2:


My experience is that NuGet uses all the sources to try and find the correct package you are looking for. We have a private nuget feed where we host our own packages and those will automatically be found when added to the project.

When we add external packages it automatically fetches from the "public" nuget store.

You also have the option to add a Source to your install command (which in most IDEs is a dropdown): https://stackoverflow.com/a/6953879/1387545



来源:https://stackoverflow.com/questions/55297944/what-nuget-sources-are-used-for-restore

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!