nuget.exe doesn't restore all packages - nuget

When I run:
nuget.exe restore c:\path\to\my.sln
It creates directory c:\path\to\packages, but it only restores one of 4 nuget packages used by the solution. It only restores EntityFramework.6.2.0.
When I open the same solution in Visual Studio and rebuild, then my c:\path\to\packages\ directory also contains:
EPPlus.4.5.3.1\
NPOI.2.4.1\
SharpZipLib.1.0.0\
The solution only contains a single project.
Why does nuget.exe restore not restore all packages, instead of just restoring one of them?
Is there some command line argument to retrieve non-Microsoft packages? I didn't see one in the Nuget docs.

I updated nuget,
nuget.exe restore c:\path\to\my.sln
...and that seems to have solved the issue. I was previously using version 2.X.

Related

I have many solution files in one repository, i want all solution files to restore using nuget ina single command

I have many solution files in one repository, i want all solution files to restore using nuget using a single command.
Or is there any other way instead of giving all solution file names one by one
eg:
Nuget restore solution1.sln
Nuget restore solution2.sln
Nuget restore solution3.sln
i tried below command but no luck
nuget restore **'\'*.sln

Is there an equivalent to Update-package -reinstall when using nuget.exe?

I don't know why. But whenever I pull code from a repo that someone else has worked on their .csproj comes with changes that don't work on my machine. In this case, I have found that:
Sometimes running Update-Package -reinstall fixed reference problems
Sometimes opening the .csproj file and then manually removing errors works
I suspect this is something to do with the reference paths defined in the .csproj file, and that the Update-package -reinstall command fixes those references relative to the local machine that the project is being built.
is there a way to replicate the Update-package -reinstall command using nuget.exe?
you need to run nuget.exe restore packages.config -PackagesDirectory <packages_directory> where packages_directory is the directory where you want your packages to be downloaded.
You can read more about the restore operation here.
I would recommend that you standardize the build steps in a shared script in your repository. For instance -
wget https://dist.nuget.org/win-x86-commandline/latest/nuget.exe -OutFile nuget.exe
& nuget.exe restore packages.config -PackagesDirectory packages_directory
& msbuild /t:build project.csproj

Can't restore nuget packages from local repository under VS2017

I am moving from VS2015 to VS2017. I keep a local NuGet repository of stuff I'm working on that is used in other projects in a folder "D:\Development\ZNugetFeed".
I'm having to do a restore packages, and under VS2017 even though the file is there in the correct folder, and VS2017 is configured to use it as a repository, I keep getting an error "Unable to find version 'x.x.xxxx.xxxxx' of package 'y'." It then shows all the locations it says it didn't find it, including the folder it is in.
Has anyone seen this type of problem?
We solved the problem by installing IIS and the Nuget app, and then pointing VS2017 to the app.

Updating NuGet package causes Source Control error because content files are not overwritten

Quite often when installing some of the js* library packages nuget copies js files to Scripts directory of the web project and puts these files under source control.
Yet while updating the package instead of just rewriting the files nuget first removes them and then copies new versions. Because of that TFS shows the error about conflicting state: Files are scheduled for removal but present locally.
Can we somehow change this behavior or is it completely defined by the author of the package?
No, this behavior is not defined by the package author.
And since NuGet 2.5, it is allowed to overwrite content files that already exist. Check: https://docs.nuget.org/release-notes/nuget-2.5
You need to use the Update-Package command to update NuGet packages.

Should config files added by NuGet package be in source control?

We have a custom NuGet package which contains a DLL and a config file. We make use of NuGet package restore so our packages are not commit in to Perforce. When the package is installed to the solution it adds a reference to the DLL and the config file is included in the root of the project. Both of these are desirable, but should the config file be checked in to source control?
Our CI environment breaks when the file is not checked in, but the package has been downloaded correctly. It looks like this is the correct NuGet behaviour, but I'm not sure what the suggested best practice it is with regards to content files and how they should be treated in version control. Do all content files added from packages need to be checked in?
NuGet package restore will only restore files into the packages directory.
Files that are copied into your project when installing a NuGet package should be checked into source control since they will not be restored.