无法构建 Godot mono 项目“命名空间名称‘Godot’”找不到”
我正在尝试构建一个 Godot mono 项目,该项目是我刚刚从我的存储库中克隆的,可以在我的另一台机器上运行。
当我尝试在 Visual Studio 中构建时,出现错误,
error CS0246: The type or namespace name 'Godot' could not be found (are you missing a using directive or an assembly reference?)
我可以通过在 Godot 中创建一个基本的空场景项目并在 Visual Studio 中打开新解决方案并尝试构建来复制此错误。
I'm trying to build a Godot mono project that I've just cloned from my repo that works on my other machine.
When I try to build in Visual Studio I get the error
error CS0246: The type or namespace name 'Godot' could not be found (are you missing a using directive or an assembly reference?)
I can replicate this by creating a basic empty scene project in Godot and opening the new solution in Visual Studio and trying to build.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在以下几种情况下,可能会出现此问题:
解决方案位于 KellyThomas 对 Github 问题的回复 此处
因此,项目未构建的原因是您的 IDE 或构建系统没有所需的 dll,当您从那里运行构建时,通常由 Godot 程序本身将其放置在那里。
对于本地开发机器,解决方案是在 Godot 中构建或运行项目一次,它将把 dll 放置在正确的文件夹中,该文件夹将保留允许其他应用程序(即 Visual Studio 或 Rider)创建构建(如果您使用 Rider) Godot 插件我相信它会为你创建 dll)。
方法有点不同,因为我们每次都从头开始,当我们可以使用 MSBuild 之类的东西时,我们不一定要运行 Godot Build。
我的解决方案是在工作目录之外存储所需 DLL 的副本,并在运行 MSBuild 步骤之前将其复制到构建文件夹中。
在撰写本文时,构建 Godot 3.4.4 Mono 项目所需的 DLL 是
GodotSharp.dll
。我怀疑每次升级 Godot 时你都必须复制这个 DLL 的新版本。手动构建一次 Godot 项目来生成 DLL(基本的 hello world 就可以了)。在 Godot 应用程序中构建项目后,DLL 存储在项目的解决方案文件 (.sln) 旁边的文件夹中。该文件夹取决于您的构建的配置。
在 OSX 中,.mono 文件夹是隐藏的,按
cmd + shift + .
可在查找器中查看该文件夹。这就是我使用 yaml 管道将文件复制到 Azure Devops 上正确文件夹的方法。
There are a few scenarios where this issue can present itself:
The solution is in a response from KellyThomas on a Github issue here
So the reason the project isn't building is that your IDE or build system doesn't have the required dll that is normally put there by the Godot program itself when you run a build from there.
For a local Dev machine the solution is to build or run the project in Godot once and it will place the dll in the correct folder where it will remain allowing builds to be created by other applications ie Visual Studio or Rider(if you use the Rider plugin for Godot I believe it will create the dll for you).
On a CI the approach is a bit different as we're starting fresh every time and we don't necessarily want to run Godot Build when we can use something like MSBuild.
My solution to this is to store a copy of the required DLL outside the working directory and copy it to the build folder before the MSBuild step is run.
The required DLL for building Godot 3.4.4 Mono projects at the time of writing is
GodotSharp.dll
. I suspect you will have to copy a new version of this DLL every time you upgrade Godot.Do a manual one time build of a Godot project to generate the DLL (basic hello world is fine). After building the project in the Godot Application the DLL is stored in a folder next to the solution file (.sln) for the project. The folder depends on the configuration of your build.
In OSX the .mono folder is hidden, press
cmd + shift + .
to see the folder in the finder.This is how I get the file copied to the correct folder on Azure Devops using a yaml pipeline.