0

Update: So, I logged on to the server and opened the project with VS 2013. I clicked "enable nuget package restore" on the solution context menu. Now, it builds on the server. The problem is, I don't know how to do the same thing in VS 2015. There is no right-click menu. I have already enabled "allow automatic package restore" in Options. -End update

I have a project in Visual Studio 2015. I can build and run it successfully on my local machine. It uses Newtonsoft.Json (JSON.net) which it obtains from Nuget. When I check in, and my continuous integration build runs on the build server, it throws an exception that it cannot locate the JSON.net assemblies:

The type or namespace name 'Newtonsoft' could not be found (are you missing a using directive or an assembly reference?) C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Microsoft.Common.targets (1605): 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. 

I have looked all over to see what is causing the Nuget package to fail. Is it because I am using Visual Studio 2015? Is Nuget jacked up?

Has anyone experienced this issue?

1 Answer 1

1

Check the references in your project carefully against the entry in your packages.config file.

I had this same error and found that the project referenced Newtonsoft.Json 4.5.1 in its references, but in packages.config, the entry was as follows:

<package id="Newtonsoft.Json" version="5.0.8" targetFramework="net45" /> 

Changing the entry in packages.config to 4.5.1 instead of 5.0.8 fixed the problem.

<package id="Newtonsoft.Json" version="4.5.1" targetFramework="net45" /> 

I discovered this by examining the local _work folder on my CI build server, and finding that the location that it was trying to pull the .dll from was not available in there; then I traced it back to figure out why. (Another possible cause of this issue is a NuGet package that has been deprecated. I had one of those as well that threw the same error.) I'm not sure how they got out of sync; this was a project that was originally worked on by someone else that I inherited.

Hopefully, even if this doesn't solve the problem for you, this will help somebody else down the road.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.