1

We have a solution that contains a project that uses TestFramework from NuGet. We've another solution that references that project.

The project/solution file system structure looks like this:

- Tests
   - Tests
       - Properties
           - AssemblyInfo.cs
       - packages.config
       - Tests.csproj
   - Tests.sln
- RefToTests
   - RefToTests.sln

RefToTests.sln contains a reference to Tests.csproj.

If I open the Tests.sln and try to build it I get an error that tells me that the referenced NuGet dependencies could not be found. No problem - open the NuGet management for solution, click restore and build it again. Works fine.

The same clean folder but now open RefToTests.sln. Same error. Same workflow. That restores the packages to RefToTest\packages. The project is looking for them at ..\packages what means Tests\packages. That will not build.

We tried to fix that by manually change the folder to the packages in the project file from ..\packages to $(SolutionDir)packages. That worked great. The missing packages are downloaded automatically (wow that doesn't work without that change).

But now let's update the package. The package manager is not able to find that references in the project file, leaves the old entries untouched and added completely new references. The project won't build in any solution. That seams to be a bug in NuGet project management. In my opinion the package resolution should crash if it finds $(SolutionDir) or the package management should be able to handle that.

But what is the solution? Changing the directory to $(SolutionDir) and check every project file after every update? Leave the specified folder as it is and never do a cleanup on the repository?

Sebastian Schumann
  • 3,204
  • 19
  • 37
  • "RefToTests.sln contains a reference to Tests.csproj" how did you reference Tests.csproj to the RefToTests.sln? Since those two project are not in the same solution, could not add project reference directly, so this is where I am confused. If possible, could you please provide some detail steps how did you do that or share me a test sample. – Leo Liu Oct 17 '17 at 07:32
  • @Leo-MSFT maybe a reference is the wrong therm. I added this existing project to the solution. In consequence there are two solutions containing the same project. – Sebastian Schumann Oct 17 '17 at 08:52
  • Have you try to also install those references to Tests.csproj to RefToTests.sln? – Leo Liu Oct 17 '17 at 09:58
  • @Leo-MSFT Sorry I don't get your point. What sould I try? I tried to change the location of the references packages from `..\packages` to `$(SolutionDir)packages`. Having that change we're able to build a clean codebase from every solution but we can't update an existing package. – Sebastian Schumann Oct 17 '17 at 11:32
  • I mean that you add the `TestFramework` to Tests project, then you refer Tests project to RefToTests project, have you also install the `TestFramework` package to the RefToTests project? Am I right? Since this issue is related to the location of the packages, so I suggest that you can try to unified path to an absolute path for all solutions, https://stackoverflow.com/questions/4092759/is-it-possible-to-change-the-location-of-packages-for-nuget – Leo Liu Oct 18 '17 at 09:35

0 Answers0