1
votes

Im using Azure Devops pipeline for build and release.

I have 1 solution with multiple projects in it, during the build process on the nuget package restore step i would like it to only restore packages for the project i deploy to

lets say i have a solution named Main.sln

i have 2 projects in it named project1.csproj and project2.csproj

the release goes well but it takes quite a while because the NuGet restore step takes every package from the Main.sln instead of per project.

I would like it to only Restore for a specific packages.config that i command it to go to in the nuget restore settings (/project1/packages.config)

i get the following error:

Cannot determine the packages folder to restore NuGet packages. Please specify either -PackagesDirectory or -SolutionDirectory
1
Are you actually supplying it -PackagesDirectory ?David C

1 Answers

2
votes

Azure Devops packages.config path in multi project solution

That because nuget packages are restored into a /packages folder alongside the selected solution file by default.

If we specify a specific packages.config/project file without solution file, nuget could not determine the packages folder to restore NuGet packages.

In this case, we need manually specify the PackagesDirectory or SolutionDirectory, so that nuget could to know where to store packages.

To resolve this issue, if you are nuget command line to restore packages, Just as prompted by the error log, using the parameter -PackagesDirectory or -SolutionDirectory to specify the folder.

If you are using classic editor, there is option Destination directory for the nuget restore task:

enter image description here

You can specify the folder to store the packages.

Hope this helps.