Reputation: 6282
I have this structure of solutions and projects:
projects
|--.nuget
| |--packages.config
|
|--projFolderA
| |--projectA.csproj
|
|--projFolderB
| |--projectB.csproj
|
|--projFolderC
| |--projectC.csproj
|
|--solutionAB.sln
|--solutionBC.sln
|--solutionCA.sln
Each solution is configured to use some libraries using nuget. Now, when I run:nuget restore
, I got this error: This folder contains more than one solution file.
But if I open each solution in VS2013 then it's fine.
This is the nuget settings in each of my *.sln file:
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".nuget", ".nuget", "{334B5D1D-8694-472B-8170-3D36A395DCEF}"
ProjectSection(SolutionItems) = preProject
.nuget\packages.config = .nuget\packages.config
EndProjectSection
EndProject
What did I do wrong ? How can I run nuget restore
from console in this case ?
Upvotes: 7
Views: 6467
Reputation: 20312
Try nuget restore solutionABC.sln
See https://docs.nuget.org/consume/command-line-reference
See bolded section below as to why you get the error.
Restore Command Notes
The restore command is executed in the following steps:
Determine the operation mode of the restore command.
If packages.config file is specified, nuget restores packages listed in the packages.config file.
If solution is specified, nuget restores packages for the solution's projects. In this case, nuget needs to locate the solution file.
If solution is a file, that file is used as the solution file.
If solution is a directory, then nuget searches for a *.sln file in that directory. If exactly one file is found, that file is used as the solution file. Otherwise, nuget displays an error message and exits.
If no argument is provided, nuget first looks for solution files in the current directory. If there is just one solution file, nuget will restore packages for that solution. If there are multiple solution files, an error message is displayed and nuget exits.
If there are no solution files, nuget then searches for the packages.config file in the current directory. If the file exists, nuget will restore packages listed in the packages.config file.
If there are no solution files and no packages.config file in the current directory, an error message is displayed and nuget exits.
If the operation mode is restoring for a solution, then -SolutionDirectory option is not applicable. In this case, nuget displays an error message and exits.
Upvotes: 18