Godot C#,Nuget 包 Newtonsoft 不会构建

Godot C#, Nuget Package Newtonsoft won't build

我有一个项目在家里运行良好,但由于某种原因在我的工作电脑上出现错误。 这是 运行向下。

我已经安装了.net 4.7 开发者工具 我安装了最新的 Mono

然后我重新启动了我的电脑

C# 项目,将 Nuget 添加到 .csproj 文件:

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

我有一个使用 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);
    }
}

我运行nuget restore 然后我构建了项目 msbuild

然后我尝试 运行 来自 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?)

正如我所说,这在我家里的 PC 上 100% 正常,所以不确定我在工作时是否错过了我 PC 上的一个步骤。

编辑

来自输出日志:

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.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.0.0\build\.NETFramework\v4.7\mscorlib.dll /reference:C:\Users\dustb\.nuget\packages\microsoft.netframework.referenceassemblies.net47.0.0\build\.NETFramework\v4.7\System.Core.dll /reference:C:\Users\dustb\.nuget\packages\microsoft.netframework.referenceassemblies.net47.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.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.

我找到了答案。

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

构建工具设置为 dotnet CLI

这是行不通的,所以改为MSBUILD (VS Build Tools)现在可以了。

如上面 Perry Qian-MSFT 所述,从 Nuget 添加库后 我必须在 Visual Studio 中构建解决方案,然后我才能 运行 来自 Godot 的项目。