0
votes

We recently moved from one big SLN file to multiple ones. So now the folder structure is like this:

  • Root
    • Solution1WebApp
      • packages (folder)
      • Project1 (folder)
        • Project1.csproj
      • NuGet.config
      • Solution1.sln
    • Solution2Libraries
      • packages (folder)
      • Project1 (folder)
        • Project1.csproj
      • Project2 (folder)
        • Project2.csproj
      • NuGet.config
      • Solution2.sln
    • Solution3UnitTests
      • packages (folder)
      • Project1 (folder)
        • Project1.csproj
      • Project2 (folder)
        • Project2.csproj
      • Project3 (folder)
        • Project3.csproj
      • NuGet.config
      • Solution3.sln

When I check-in in Visual Studio Online, a build is triggered. This build is configured to retrieve nuget packages (so the packages folders are not checked in).

In the csproj files of Solution1, I configured all the paths pointing to packages to be like this:

<Reference Include="Newtonsoft.Json, Version=7.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
  <HintPath>..\..\Solution1WebApp\packages\Newtonsoft.Json.7.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
  <Private>True</Private>
</Reference>

But the build keeps failing and I get warnings like this:

C:\Program Files (x86)\MSBuild\14.0\bin\amd64\Microsoft.Common.CurrentVersion.targets (1819, 5)  

    Could not resolve this reference. Could not locate the assembly "Newtonsoft.Json, Version=7.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL". Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors.

And I think these warnings are causing exceptions such as:

The type or namespace name 'xxx' does not exist in the namespace 'yyy' (are you missing an assembly reference?)

So am I missing something? Are the paths correctly configured?

Thanks for any help.

2
I dont think that it is a good idea to have your unit tests separate from there subject. You should have two solutions, both containing unit tests and the code that they test...MrHinsh - Martin Hinshelwood
Thanks MrHinsh for the hint. For the sake of clarity I did not mention it there, but yes the web app is referencing the unit tests projects so that we have everything available when opening the Web App.DotNetMatt

2 Answers

2
votes

Ok I found the answer. The packages path must remain without the solution name:

<Reference Include="Newtonsoft.Json, Version=7.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
  <HintPath>..\packages\Newtonsoft.Json.7.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
  <Private>True</Private>
</Reference>

In VSO build definition, I added a build step for each of the solution (one step for the Libraries, one for the Unit Tests and one for the Web App).

This way, each solution is being built and the paths can remain the same as locally on our PC.

0
votes

remove the references and the items that it mentions in the packages.json file.

add them back in to the project within the solution that its doesn't find the files.

save and commit.. worked for me.