Friday, May 15, 2020

DevOps Visual Studio Build Could Not resolve reference


Although my project could build fine without any errors on laptop, devops visual studio build task could not resolve reference of NewtonSoft.Json nuget package for some reason.

Actual warning was:

Could not resolve this reference. Could not locate the assembly "Newtonsoft.Json, Version=12.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.

Which further caused build to fail with error:

The type or namespace name 'Newtonsoft' could not be found (are you missing a using directive or an assembly reference?)

Such errors can be resolved by adding the related .dll files to source control. 

The details steps are:

  1. Build the solution in laptop.
  2. Select the project which fails to build
  3. In the solution explorer click on show all files at the top.

  4. Then expand bin/debug or bin/release folders
  5. Right click on Newtonsoft.Json.dll and select 'Add Ignored File to Source Control' command.
  6. Right click again on the file and select 'Include in Project' command.
  7. Lastly check in the project and build on devops



Update: There are some more related errors which can be solved in a similary way

Could not load file or assembly 'Microsoft.IdentityModel, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.




Could not load file or assembly 'Microsoft.IdentityModel.Extensions, Version=2.0.0.0, Culture=neutral, PublicKeyToken=69c3241e6f0468ca' or one of its dependencies. The system cannot find the file specified.




No comments:

SSL Error - The connection for this site is not secure

 After cloning a git repo of dot net framework website and trying to run it all I could see was this error Turns out the fix was to simply e...