And nuget restore dotnet restore about the same: they perform a NuGet restore operation.
The only difference: dotnet restore is a convenient shell for invoking dotnet msbuild/t:Restore which invokes recovery integrated into MSBuild. This only works on MSBuild distributions that include NuGet, such as Visual Studio 2017 (full Visual Studio, build tools) or Mono 5. 2+ (=> msbuild/t:Restore ) and the .NET Core SDK, which provides this convenient command ,
There are currently two ways to use NuGet packages in projects (actually three, but for now, let's ignore project.json in UWP):
packages.config : The "classic" way of referencing NuGet packages. This suggests that NuGet is a standalone tool, and MSBuild knows nothing about NuGet. A NuGet client, such as nuget.exe or tools integrated with Visual Studio, sees the packages.config file and downloads the specified packages to a local folder during recovery. Installing the package modifies the project to reference resources from this local folder. Thus, the recovery for the packages.config project only downloads files.PackageReference : The project contains MSBuild elements that reference the NuGet package. Unlike packages.config , only direct dependencies are listed, and the project file does not directly refer to any resources (DLL files, content files) from the packages. During recovery, NuGet calculates the dependency graph, evaluating direct and transitive dependencies, makes sure that all packages are loaded into the user's global package cache (not for a local solution, therefore it is loaded only once), and writes the resource file to the obj folder, it contains a list all packages and resources that the project uses, as well as additional MSBuild goals if any package contains build logic that needs to be added to the project. Thus, NuGet recovery can load packages if they are not already in the global cache and create this resource file. In addition to package links, a project can also reference CLI tools, which are NuGet packages containing additional commands that will be available to dotnet in the project directory.
Integration with msbuild recovery works only for projects such as PackageReference (.NET Standard, .NET Core by default, but it is included for any .NET project), but not for packages.config projects. If you use the new version of nuget.exe (for example, 4.3.0), it can restore both types of projects.
Your mistake related to missing types is a little more interesting: "reference assemblies" (libraries that are passed as input to the compiler) are not installed on the system, but are delivered through NuGet packages. Therefore, as long as NuGet packages are not in the global package cache or the obj/project.assets.json file has not been generated by the restore operation, fundamental types such as System.Object will not be accessible to the compiler.
Martin Ullrich
source share