0

I have two separate API projects. Each has a solution file, both following this dir layout (ApiOne/ApiTwo);

/src
  /ApiOne
    /ApiOne.sln
    /packages  
    /ApiOne
        ApiOne.csproj

I would now like to create a new solution file and add both ApiOne.csproj and ApiTwo.csproj to that solution file, which may be stored anywhere on disk. The problem I have is that when building the solution in Visual Studio the package folder will be created next to the solution file and thus the project will not build as the references are defined as ..\packages\{ref}.

Is there a way to instruct nuget to continue to create a packages folder for each project in the same location that it would if I where building the Api specific sln file?

Myles McDonnell
  • 12,943
  • 17
  • 66
  • 116
  • http://stackoverflow.com/questions/4092759/is-it-possible-to-change-the-location-of-packages-for-nuget/4197201#4197201 – Matt Ward Mar 27 '17 at 17:24
  • @MattWard I found that previously. That will (if I can make it work, I have failed so far) enable me to change the folder globally for the solution but what I actually need to do is set it per project. Perhaps this will work on a solution and project basis? Until I get it working on a solution I won't try it at the project level – Myles McDonnell Mar 27 '17 at 17:45
  • You cannot set it on a per project basic. The packages path is relative to the solution folder by default. Otherwise you can configure it in the NuGet.Config file. It can be a relative path. This file is found based on the current solution. However each project in a single solution cannot have a different packages path. – Matt Ward Mar 27 '17 at 19:05

2 Answers2

1

Is there a way to instruct nuget to continue to create a packages folder for each project in the same location that it would if I where building the Api specific sln file?

The answer is negative. Just as Matt Ward explain in comment, the repository Path is configure in the NuGet.config file in global path (%appdata%\NuGet) or in the solution folder. It can be a relative path or absolute path. But we could not use this relative path or absolute path for each project.

I'd recommend posting in the NuGet Issue Tracker to get a discussion going. The people working on it seem pretty active, so it might be something they can add support for in a future version.

Hope this can help you.

Leo Liu
  • 71,098
  • 10
  • 114
  • 135
  • Ok, I'll do that. In the mean time I think creating symlinks will satisfy my use case. – Myles McDonnell Mar 28 '17 at 05:18
  • Yes, you can try to do that. If this answer help resolve your issue, if yes, you can mark the answer which is benefit to other communities who has the same problem. If not, you can share me the latest information about this issue. Thanks. – Leo Liu Mar 28 '17 at 05:26
  • http://nuget.codeplex.com/workitem/list/basic says MOVED TO GH NOT MONITORED..are you sure this is the place to raise a ticket for this issue? – Myles McDonnell Mar 28 '17 at 05:52
0

Creating symlinks (mklink /d {link} {target}) from the package folders local to the individual sln files and the package file for the aggregate sln file enables the build to complete successfully in VS and thus satisfies my use case.

Myles McDonnell
  • 12,943
  • 17
  • 66
  • 116