I'm just start learning about dotnet, I start to interact with it using CLI , And I found myself a little overwhelmed about the following :
I Created a dotnet console app and I started writing some code and I used some NuGet packages so when I finished I tried to run my app using the dotnet run command I noticed that dotnet restore runs behind scenes.
My question is :
-If I could access to all interfaces within the Nuget that I referenced in the .csproj and use them in my app Why he needs to run dotnet restore ?( because I assumed when I reference packages that means he will do restore that's why I'm able to use classes ... provided by package in code )
-Does referencing packages in .csproj file mean bring all the code source of the packages ?
Thank you
Asked
Active
Viewed 277 times
-1

byteram
- 125
- 8
-
If you check your code into git, and then someone else clones it, they won't have the Nuget packages, so if you run, it will first restore them. – DavidG Apr 06 '21 at 14:10
-
@DavidG Thank you – byteram Apr 06 '21 at 14:18
1 Answers
0
Does referencing packages in .csproj file mean bring all the code source of the packages ?
No. NuGet packages are typically the assemblies only. (They can also be used for client side assets, like jQuery, in which case they do contain the source code because that is what you need on the client).
If I could access to all interfaces within the Nuget that I referenced in the .csproj and use them in my app Why he needs to run dotnet restore ?
Restoring covers the case where you're NuGet cache does not contain all the needed packages at the right version (eg. you've just forked a repo to make some changes).

Richard
- 106,783
- 21
- 203
- 265