I have a Visual Studio Solution in which I have several Projets.
One of the projects use NewtonSoft.Json nuget, and it was once probably at 6.0.6 version, till I updated the Nugets to the latest, 12.0.1 version.
However, in runtime it was asking me for the incompatible 6.0.0.0 version, so I discovered that when I build the project it uses my windows \Users\myuser\.nuget\packages
folder, in which there is Newtonsoft.json\6.0.6\
directory along with the 6.0.4
and the latest at day 12.0.1
. So removed all the directories but the latest.
Now the compilation does not succeed, because
Error The package Newtonsoft.Json with version 6.0.6 could not be found in C:\Users\my-user.nuget\packages. Run a NuGet package restore to download the package. MyProject C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\Microsoft\NuGet\15.0\Microsoft.NuGet.targets 186
When I build with diagnostic log, I have in the output
9>PkgAutoMapper = C:\Users\my-user\.nuget\packages\automapper\3.2.1
9>PkgDefApplicationConfigFile = C:\Users\my-user\AppData\Local\Microsoft\VisualStudio\15.0_956f6176\devenv.exe.config
9>PkgjQuery = C:\Users\my-user\.nuget\packages\jquery\1.10.2
9>PkgModernizr = C:\Users\my-user\.nuget\packages\modernizr\2.6.2
9>PkgNewtonsoft_Json = C:\Users\my-user\.nuget\packages\newtonsoft.json\6.0.6
9>PkgWebGrease = C:\Users\my-user\.nuget\packages\webgrease\1.5.2
Where the hell it finds that 6.0.6
reference, I have no idea. I reinstalled multiple times the nuget Newtonsoft.json and it seems there is any old version, but the latest 12... I even searched with the Notepad in all files in the solution directory for 6.0.6
didn't find any file containing such a combination...
I spent several days and don't understand where is the problem...
My packages.config
:
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Antlr" version="3.5.0.2" targetFramework="net472" />
<package id="bootstrap" version="4.3.1" targetFramework="net472" />
<package id="CommonServiceLocator" version="2.0.4" targetFramework="net472" />
<package id="jQuery" version="3.3.1" targetFramework="net472" />
<package id="jQuery.Validation" version="1.17.0" targetFramework="net472" />
<package id="Microsoft.AspNet.Mvc" version="5.2.7" targetFramework="net472" />
<package id="Microsoft.AspNet.Razor" version="3.2.7" targetFramework="net472" />
<package id="Microsoft.AspNet.WebPages" version="3.2.7" targetFramework="net472" />
<package id="Microsoft.jQuery.Unobtrusive.Validation" version="3.2.11" targetFramework="net472" />
<package id="Microsoft.Web.Infrastructure" version="1.0.0.0" targetFramework="net45" />
<package id="Modernizr" version="2.8.3" targetFramework="net472" />
<package id="Newtonsoft.Json" version="12.0.1" targetFramework="net472" />
<package id="popper.js" version="1.14.3" targetFramework="net472" />
<package id="System.Runtime.CompilerServices.Unsafe" version="4.5.2" targetFramework="net472" />
<package id="Unity" version="5.10.3" targetFramework="net472" />
<package id="Unity.Abstractions" version="4.1.3" targetFramework="net472" />
<package id="Unity.Container" version="5.10.3" targetFramework="net472" />
<package id="Unity.Mvc" version="5.10.1" targetFramework="net472" />
<package id="WebActivatorEx" version="2.2.0" targetFramework="net472" />
</packages>
From my.csproj file:
<Reference Include="Newtonsoft.Json, Version=12.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\..\MyFront\packages\Newtonsoft.Json.12.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
<Private>True</Private>
</Reference>
Project's WebConfig:
<dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-12.0.0.0" newVersion="12.0.0.0" />
</dependentAssembly>
New Solution and new project
I tried to create a new project as "Empty Web Project" when it tries to add it so the solution an error message appears:
== Microsoft Visual Studio ==
Could not load file or assembly 'Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
I repaired Visual Studio... (I start to hate Visual Studio), spent half a day to repair it, but any success... I now try to recreate a new solution with new projects from the existing code
User contributions licensed under CC BY-SA 3.0