2

The Problem

My builds keep failing due to"

C:\Program Files (x86)\MSBuild\14.0\bin\amd64\Microsoft.Common.CurrentVersion.targets (1820): Could not resolve this reference. Could not locate the assembly "Newtonsoft.Json, Version=10.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 spent a bunch of time trying to bug swat this and I have come up blank. Any kind of help would be highly appreciated!

When I RDP into my build server and browse the packages folder of the build, NewtonSoft.Json is not there. For some reason it is not being downloaded, however, when I build it on my local computer it downloads it just fine.

What I have tried:

  1. I have checked that no packages folder exists in source control
  2. I have upgraded nuget.exe to the latest version (4.3.0) and then downgraded back down to 3.4.4 (this upgrade broke everything)
  3. I have deleted the builds folder on the build server
  4. I have inspected my web config file which has this:

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

  1. I have inspected my .csproj file which has this:

<dependentAssembly> <assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" /> <bindingRedirect oldVersion="0.0.0.0-10.0.0.0" newVersion="10.0.0.0" /> </dependentAssembly>

  1. I have checked my NuGet.Config file which has this:

<?xml version="1.0" encoding="utf-8"?> <configuration> <solution> <add key="disableSourceControlIntegration" value="true" /> </solution> <packageSources> <add key="NuGet.Org Ver 3" value="https://api.nuget.org/v3/index.json" /> <add key="NuGet official package source" value="https://nuget.org/api/v2/" /> </packageSources> <disabledPackageSources /> </configuration>

  1. I have checked my packages.config file which has this:

<package id="Newtonsoft.Json" version="10.0.3" targetFramework="net452" />

I am running Visual Studio 2015 Update 3

Build server is TFS 2013

Solved (but I shouldn't have to do this, something is very wrong) I solved it by simply downgrading NewtonSoft.Json to 9.0.1

Talon
  • 3,466
  • 3
  • 32
  • 47

1 Answers1

0

First you could try to build your project in local. If your local build is successful and just the TFS build is failing then it is usually due to dll reference issue. Make sure that the Dll is referenced as a relative path in the project file (.csproj).

And also check the references in your project carefully against the entry in your packages.config file.

In your case, this issue may related to VS2015 and a NuGet package with dependency on Newtonsoft.Json version=10.0.3, please refer the answer from user1467813 in this question: 'Newtonsoft.Json' already has a dependency defined for 'Microsoft.CSharp'

PatrickLu-MSFT
  • 49,478
  • 5
  • 35
  • 62