【问题标题】:How can I use Godot 4.0 C# with dotnet run watch?如何将 Godot 4.0 C# 与 dotnet run watch 一起使用?
【发布时间】:2022-10-17 10:49:59
【问题描述】:

Godot 4.0 beta 附带了 C# 支持,据报道,它在 Visual Studio 中支持热重载,开箱即用。

我想让它在我没有 Visual Studio 的 Mac 上运行。我将launchSettings.json 放入我的Godot 项目中的“Properties/launchSettings.json”中,其中包含以下内容(取自Visual Studio 自动生成的内容):

{
  "profiles": {
    "Development": {
      "commandName": "Executable",
      "executablePath": "/path/to/Godot_csharp_b1.app/Contents/MacOS/Godot",
      "commandLineArgs": "--debug-server tcp://127.0.0.1:6666",
      "workingDirectory": "/path/to/my/project",
      "authenticationMode": "None",
      "remoteDebugEnabled": false,
      "remoteDebugMachine": ""
    }
  }
}

现在我尝试这样做:

dotnet watch run --launch-profile Development

但是,它不起作用。它给出了这个错误:

The launch profile "Development" could not be applied.
The launch profile type 'Executable' is not supported.
Unable to run your project.
Ensure you have a runnable project type and ensure 'dotnet run' supports this project.
A runnable project should target a runnable TFM (for instance, net5.0) and have OutputType 'Exe'.
The current OutputType is 'Library'.

有可能解决这个问题吗?我可以接受任何在 MacOS 上通过热重载运行 Godot 的方式——命令行或其他任何方式。

如果这很重要,我在 MacOS + M1 上。

【问题讨论】:

    标签: c# godot dotnet-cli


    【解决方案1】:

    如果您尝试使用 Visual Studio Code 调试 Godot 4 C# 项目,则可以使用以下 launch.json 配置进行调试。请注意,Visual Studio 和 Visual Studio Code 是两个完全不同的 IDE。只需将下面的 sn-p 放在 Godot 项目中.vscode/launch.json 的文件中:

    {
      "version": "0.2.0",
      "configurations": [
        // For these launch configurations to work, you need to setup a GODOT4
        // environment variable. On mac or linux, this can be done by adding
        // the following to your .zshrc, .bashrc, or .bash_profile file:
        // export GODOT4="/Applications/Godot.app/Contents/MacOS/Godot"
        {
          "name": "Play",
          "type": "coreclr",
          "request": "launch",
          "preLaunchTask": "build",
          "program": "${env:GODOT4}",
          "args": [],
          "cwd": "${workspaceFolder}",
          "stopAtEntry": false,
        },
      }
    }
    

    确保你有一个指向 Godot4 可执行文件的 GODOT4 环境变量。

    您还需要将下面的 sn-p 放在您的 .vscode/tasks.json 文件中,因为上面的启动配置依赖于它来确保在调试之前运行 dotnet build

    {
      "version": "2.0.0",
      "tasks": [
        {
          "label": "build",
          "command": "dotnet",
          "type": "process",
          "args": [
            "build"
          ],
          "problemMatcher": "$msCompile",
          "presentation": {
            "echo": true,
            "reveal": "silent",
            "focus": false,
            "panel": "shared",
            "showReuseMessage": true,
            "clear": false
          }
        }
      ]
    }
    

    如果您正在寻找 Godot 3 launch.json 配置,you can find those here

    【讨论】:

      猜你喜欢
      • 2021-11-07
      • 1970-01-01
      • 2016-09-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-12-07
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多