Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

dotnet build and custom target with a depenedency on Json.Net: File name: 'Newtonsoft.Json, Version=, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed'

See original GitHub issue

@abatishchev commented on Thu Jun 21 2018

Hi, I have a project (Service Fabric if that matters) which uses a custom props and targets files which call a DLL winch has a dependency on Newtonsoft.Json.dll which is shipped alongside. When I build inside VS2017 I have no errors. But when I run dotnet build I’m getting this:

BuildLayout.targets(21,5): error MSB4018: The “GenerateArmTemplateTask” task failed unexpectedly. [DeploymentAgent.sfproj] BuildLayout.targets(21,5): error MSB4018: System.IO.FileLoadException: Could not load file or assembly ‘Newtonsoft.Json, Version=, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed’. Could not find or load a specific file. (Exception from HRESULT: 0x80131621) [DeploymentAgent.sfproj] BuildLayout.targets(21,5): error MSB4018: File name: ‘Newtonsoft.Json, Version=, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed’ [DeploymentAgent.sfproj] BuildLayout.targets(21,5): error MSB4018: at BuildLayout.Generators.TemplateGenerator.Generate(BuildLayoutOptions args, ApplicationManifestType appManifest) [DeploymentAgent.sfproj] BuildLayout.targets(21,5): error MSB4018: at BuildLayout.Generators.BuildLayoutGenerator.Generate(BuildLayoutOptions args) in e:\bt\921388\repo\src\product\buildlayout\Generators\BuildLayoutGenerator.cs:line 23 [DeploymentAgent.sfproj] BuildLayout.targets(21,5): error MSB4018: at BuildLayout.Tasks.GenerateArmTemplateTask.Execute() in e:\bt\921388\repo\src\product\buildlayout\Tasks\GenerateArmTemplateTask.cs:line 46 [DeploymentAgent.sfproj] BuildLayout.targets(21,5): error MSB4018: at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute() [DeploymentAgent.sfproj] BuildLayout.targets(21,5): error MSB4018: at Microsoft.Build.BackEnd.TaskBuilder.ExecuteInstantiatedTask(ITaskExecutionHost taskExecutionHost, TaskLoggingContext taskLoggingContext, TaskHost taskHost, ItemBucket bucket, TaskExecutionMode howToExecuteTask) [DeploymentAgent.sfproj] BuildLayout.targets(21,5): error MSB4018: [DeploymentAgent.sfproj]

Please help me to understand how it works and why i’m getting it.

@abatishchev commented on Tue Jun 26 2018


Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:14 (4 by maintainers)

github_iconTop GitHub Comments

abatishchevcommented, Dec 7, 2018

I think the source of confusing was that AssemblyVersion for all releases in 11.x.x is 11.0.0. Give it a try and please let me know.

shwantoncommented, Dec 7, 2018

I’m seeing the same error when running dotnet build from the cli after adding the Mobile.BuildTools package. It has a dependency on Newtonsoft.Json 11.0.2

/Users/username/.nuget/packages/mobile.buildtools/,5): error : Could not load file or assembly 'Newtonsoft.Json, Version=, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed'. Could not find or load a specific file. (Exception from HRESULT: 0x80131621) [/Users/username/Projects/DotNetBuildErrorExample/DotNetBuildErrorExample/DotNetBuildErrorExample.csproj]


I’m not sure why it’s trying to find since that isn’t what the package is requiring.

I’ve added a repro repo If you try and build the project from the cli you’ll see the error.

dotnet --info

.NET Core SDK (reflecting any global.json):
 Version:   2.1.302
 Commit:    9048955601

Runtime Environment:
 OS Name:     Mac OS X
 OS Version:  10.13
 OS Platform: Darwin
 RID:         osx.10.13-x64
 Base Path:   /usr/local/share/dotnet/sdk/2.1.302/

Host (useful for support):
  Version: 2.1.2
  Commit:  811c3ce6c0

.NET Core SDKs installed:
  2.1.302 [/usr/local/share/dotnet/sdk]

.NET Core runtimes installed:
  Microsoft.AspNetCore.All 2.1.2 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.App 2.1.2 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 2.1.2 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]

To install additional .NET Core runtimes or SDKs:
Read more comments on GitHub >

github_iconTop Results From Across the Web

How can I fix assembly version conflicts with JSON.NET ...
Here the steps I used to fix the warning: Unload project in VS; Edit .csproj file; Search for all references to Newtonsoft.Json assembly....
Read more >
Solved: Could not load file or assembly 'Newtonsoft.Json
Solved: Could not load file or assembly 'Newtonsoft.Json, Version=' when i try to login power bi gateway.
Read more >
MSB3277: Found conflicts between different versions of ' ...
This error occurs during a build when more than one version of the same dependent assembly is referenced in a build of the...
Read more >
How to resolve .NET reference and NuGet package version ...
In .NET, this issue is solved. We will usually ship DLL files separately for each application. Alternatively, we can use the GAC for...
Read more >
VS : How to solve Could not load file or assembly ...
I was working on my ASP.NET MVC application recently and I needed to do some serialization/deserialization work on JSON data.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Post

No results found

github_iconTop Related Hashnode Post

No results found