0% found this document useful (0 votes)
91 views3 pages

Fixing Godot C# Newtonsoft Build Error

The document describes an issue where a Godot C# project using the Newtonsoft.Json NuGet package was failing to build on one PC but not another. The solution was to change the Godot editor setting for build tool from dotnet CLI to MSBUILD (VS Build Tools).
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
91 views3 pages

Fixing Godot C# Newtonsoft Build Error

The document describes an issue where a Godot C# project using the Newtonsoft.Json NuGet package was failing to build on one PC but not another. The solution was to change the Godot editor setting for build tool from dotnet CLI to MSBUILD (VS Build Tools).
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

visual studio - Godot C#, Nuget Package Newto... https://stackoverflow.com/questions/63464979/...

Godot C#, Nuget Package Newtonsoft won't build


Asked 2 months ago Active 2 months ago Viewed 156 times

By using our site, you acknowledge that you have read and understand our Cookie Policy, Privacy
Policy, and our Terms of Service.

1 sur 3 24/10/2020 à 02:48


visual studio - Godot C#, Nuget Package Newto... https://stackoverflow.com/questions/63464979/...

I have a project that at home is working fine, but for some reason on my work PC is
getting an error. Here is the rundown.
0
I have installed .net 4.7 Developer tools I have installed the latest Mono

I have then restarted my PC

C# project, with a Nuget added to the .csproj file:

<PackageReference Include="Newtonsoft.Json">
<Version>12.0.3</Version>
</PackageReference>

I have a simple code file that is using Newtonsoft:

using Godot;
using Newtonsoft.Json;

public partial class Node2D : Godot.Node2D


{
// Called when the node enters the scene tree for the first time.
public override void _Ready()
{
//Json serialization.
var tempclasss = new TestClass
{
testprop1 = 40,
testprop2 = "meep"
};
var serialized = JsonConvert.SerializeObject(tempclasss);
GD.Print(serialized);
}
}

I ran nuget restore I then built the project msbuild

I then tried to run the project from Godot

Node2D.cs(2,7): error CS0246: The type or namespace name 'Newtonsoft' could


not be found (are you missing a using directive or an assembly reference?)

As I said, this works 100% fine on my PC at home, so not sure if I missed a step on
my PC at work.

EDIT

From output Log:

By using our site, you acknowledge that you have read and understand our Cookie Policy, Privacy
Project "CsharpTutorial.sl (Build target( )):
Policy, and our Terms of Service
Message: Build .
Project "Cshar default targets):

2 sur 3 24/10/2020 à 02:48


visual studio - Godot C#, Nuget Package Newto... https://stackoverflow.com/questions/63464979/...

probably this will help you stackoverflow.com/questions/11697479/… – bthn Aug 18 at 8:53

Thank you, I had already read this article. It sadly didn't offer a solution to my issue. Theirs is a
deploy issue, mine is a build issue in Godot. – Mark Johnson Aug 18 at 9:06

Please try to run dotnet build for your new sdk project to check whether it helps or not.
– Perry Qian-MSFT Aug 18 at 10:06

have you tried removing newtonsoft from project and then adding it again from nuget? – bthn
Aug 18 at 10:26

@PerryQian-MSFT dotnet build shows the same error. Tried running dotnet restore then
dotnet build ... same error. Bear in mind this is targeting .NET 4.7 running nuget
restore , then msbuild builds fine in the terminal, however Godot still won't run project,
claiming Newtonsoft if not found. – Mark Johnson Aug 18 at 11:13

1 Answer Active Oldest Votes

I have found the answer.

1 Godot -> Editor -> Editor Settings -> Mono -> Builds

Build Tool was set to dotnet CLI

This was not working, so changed to MSBUILD (VS Build Tools) this is now working.

answered Aug 18 at 13:05


Mark Johnson
337 2 15

By using our site, you acknowledge that you have read and understand our Cookie Policy, Privacy
Policy, and our Terms of Service.

3 sur 3 24/10/2020 à 02:48

You might also like