1

I'm using the TFS step to restore my NuGet packages. In the "Path to solution or packages.config" field I'm setting the path to the sln file. The problem that I'm getting is that in my solution I have 2 projects:

Project "A" referencing "commom.package" version 1.1 and

project "B" referencing "commom.package" version 1.3

After the restore step I'm only getting the 1.3 version in the package directory, and after project "A" got compiled I can see in the "bin\release" folder that It's having the 1.3 version instead of the 1.1.

How can I solve this issue? Do I need to set restore for every project in the solution - meaning every package.config file?

Aviram Fireberger
  • 3,910
  • 5
  • 50
  • 69

1 Answers1

1

The nuget restore task is just using nuget.exe command to restore the packages. If you use the nuget.exe command in local, will also get the same result. Package.conifg is project level, not solution level. So if you directly restore the solution in this case, it will only get one version 1.3 which apply to both projects.

However in VS , there is an option Automatically check for missing packages during build in Visual Studio. You will get both version 1.1 and 1.3 in VS restore.

enter image description here

To resolve this issue you have to set restore for every package.config file. Unlike restore the whole solution, you also need to use -PackagesDirectory in NuGet Arguments of the task.

Community
  • 1
  • 1
PatrickLu-MSFT
  • 49,478
  • 5
  • 35
  • 62
  • Well... I have about 40 projects in my solution, Doesn't sound a good solution by the TFS system to "Hard-Coded" every package.config file. In this case I'll need to add 40 build step and manually write them. When I compiling throw VS it's working with the "Auto" flag. But in the TFS build which bring my team the official releases it doesn't work – Aviram Fireberger May 28 '17 at 06:15
  • 1
    @AviramFireberger However, this is by designed of `NuGet.exe` command. The NuGet team deprecated solution level packages in NuGet 3.0. *Source Link: https://stackoverflow.com/questions/33352258/how-do-i-create-a-pure-solution-level-nuget-package* . Usually Version 1.3 will support down-level compatibility of 1.1, why you insist on using version 1.1 for project "A" – PatrickLu-MSFT May 31 '17 at 01:52
  • 1
    Thanks for the link, The reason I'm insist to use 1.1 for project "A" is that it's referencing another NuGet package that needs also version 1.1 of that package and 1.3 doesn't seems to implement the classes this second NuGet needs and this causing my code to break – Aviram Fireberger Jun 01 '17 at 13:49