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.
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:
Project "CsharpTutorial.sln" (Build target(s)):
Message: Building solution configuration "Debug|Any CPU".
Project "CsharpTutorial.csproj" (default targets):
Skipping target "GenerateTargetFrameworkMonikerAttribute" because all output files are up-to-date with respect to the input files.
Csc: C:\Program Files\dotnet\dotnet.EXE exec "C:\Program Files\dotnet\sdk\3.1.401\Roslyn\bincore\csc.dll" /noconfig /nowarn:1701,1702 /nostdlib+ /errorreport:prompt /warn:4 /define:GODOT_WINDOWS;GODOT_64;GODOT;DEBUG;TOOLS /highentropyva+ /reference:C:\Users\dustb\source\personalRepos\godotlearning\CSharpLearning\.mono\assemblies\Debug\GodotSharp.dll /reference:C:\Users\dustb\source\personalRepos\godotlearning\CSharpLearning\.mono\assemblies\Debug\GodotSharpEditor.dll /reference:C:\Users\dustb\.nuget\packages\microsoft.netframework.referenceassemblies.net47\1.0.0\build\.NETFramework\v4.7\mscorlib.dll /reference:C:\Users\dustb\.nuget\packages\microsoft.netframework.referenceassemblies.net47\1.0.0\build\.NETFramework\v4.7\System.Core.dll /reference:C:\Users\dustb\.nuget\packages\microsoft.netframework.referenceassemblies.net47\1.0.0\build\.NETFramework\v4.7\System.dll /debug+ /debug:portable /optimize- /out:.mono\temp\obj\Debug\CsharpTutorial.dll /subsystemversion:6.00 /target:library /utf8output /langversion:7.3 Properties\AssemblyInfo.cs SayHello.cs ".mono\temp\obj\Debug\.NETFramework,Version=v4.7.AssemblyAttributes.cs"
Csc: Using shared compilation with compiler from directory: C:\Program Files\dotnet\sdk\3.1.401\Roslyn\bincore
SayHello.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?) [C:\Users\dustb\source\personalRepos\godotlearning\CSharpLearning\CsharpTutorial.csproj]
Done building project "CsharpTutorial.csproj" -- FAILED.
Done building project "CsharpTutorial.sln" -- FAILED.
I have found the answer.
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.