question

MahfuzurRahman-1847 avatar image
0 Votes"
MahfuzurRahman-1847 asked karenpayneoregon commented

Where does Nuget store details about the sources from where it gets the packages

Hi there. I am learning C# with visual studio. I recently discovered about nuget and the benefits that it provide. But, I am really curious to know does it stores the links or details about the sources from where it downloads the packages. After light digging around myself, I was able to find out the visual studio shows sources in the package manager setting. Also, I was able to find that I can print out the sources in console by using dotnet cli. But, I am really curious to know, is there are any configuration file or something like that where it stores all the information and where it is.

I will be really grateful to you if you kind answer my queries. Thanks in advance.

dotnet-csharp
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

karenpayneoregon avatar image
0 Votes"
karenpayneoregon answered karenpayneoregon commented

The author of a package sets properties under project properties and target Frameworks (read this page) and this page, manifest and package configuration file. Also see How NuGet resolves package dependencies.

There are also PowerShell commands and arguments

Internally on NuGet a private database stored all package details.


· 7
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

I am extremely sorry, probably my question was not clear.
95299-screenshot-2021-05-10-232040.png

Please take a look at this image. As you can see, after running the "dotnet nuget list source" command, it outputted the sources from where nuget will get the packages. I wanted to know where does nuget stores this details.

0 Votes 0 ·

As mentioned in my original reply on NuGet details are stored in a database and locally package references are stored without details in the project file in a ItemGroup.

Also, NuGet stores package information under C:\Users\xxxxx\.nuget\packages
95320-figure1.png


0 Votes 0 ·
figure1.png (12.3 KiB)

Thank you for the reply. I have recently came across a stackoverflow post where someone was talking about Nuget.config file in "%AppData%/Roaming/Nuget/Nuget.config", which contains this text:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />
</packageSources>
</configuration>

If you don't mind can you explain me what is the use of this file?


0 Votes 0 ·
Show more comments
TimonYang-MSFT avatar image
0 Votes"
TimonYang-MSFT answered

When you download the nuget package, there will be a .nuspec file that stores some basic information about the package.

.nuspec reference

The path is as Karen said, this is an example of EntityFramework:

95397-3.png


If the response is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


3.png (49.6 KiB)
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.