|
|
|
|
Reply From: |
vannongtinh |
I’m currently working on fixing bugs in the Godot_mono_version_4.0, but I’m facing difficulties with the configuration process. I have followed all the steps provided in the Compiling with .NET guide, but unfortunately, it’s not functioning as expected.
Upon clicking the “build” button in the editor, I encountered two errors that are related to the “Godot.NET.Sdk/4.1.0-dev” package. The first error message states: Unable to find package Godot.Net.Sdk with version (=4.1.0-dev) - Found 43 version(s) in nuget.org [ Nearest 4.1.0-dev.1
. This indicates that the specified package version cannot be located, and it suggests using the nearest available version.
The second error message states: The SDK 'Godot.NET.Sdk/4.1.0-dev' specified could not be found.
This means that the specified SDK mentioned in the project file cannot be found on the machine.
The *.csproj file of the newly created project, which was built using the binary, displays the following settings:
<Project Sdk="Godot.NET.Sdk/4.1.0-dev">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<EnableDynamicLoading>true</EnableDynamicLoading>
<RootNamespace>Empty.development</RootNamespace>
</PropertyGroup>
</Project>
After spending a day troubleshooting, I realized that the instructions I followed were likely tailored for Linux, and since I am using Windows 10, that might be the reason why it’s not working. Furthermore, the example I referred to was missing the step “dotnet nuget add source,” which resulted in the error: “The SDK 'Godot.NET.Sdk/4.1.0-dev” occurrence.
I have revised the instructions to make them more accurate, and now it is working. Here are the revised steps:
- My intention is to debug the Godot source code, so I invoke scons with the following options:
scons dev_build=yes dev_mode=yes vsproj=yes module_mono_enabled=yes
- After completing step 1, running the editor will prompt a message
stating “.NET runtime is missing.”
Failed to load .NET runtime
Unable to load .NET runtime, no compatible version was found.
Attempting to create/edit a project will lead to a crash.
Please install the .NET SDK 6.0 or later from
https://dotnet.microsoft.com/en-us/download and restart Godot.
This bug occurs because of missing the configuration file. Just continue with the steps below.
here is the bug report. To resolve this issue, I need to build .NET assemblies:
python ./modules/mono/build_scripts/build_assemblies.py --godot-output-dir=./bin --godot-platform=windows
- Then, generate glue sources as usual:
./bin/godot.windows.editor.dev.x86_64.mono.exe --headless --generate-mono-glue modules/mono/glue
- Re-build the .NET assemblies again. It is uncertain whether this
step is necessary:
python ./modules/mono/build_scripts/build_assemblies.py --godot-output-dir=./bin --godot-platform=windows
- Ensure that the nuget source is clean:
dotnet nuget remove source MyLocalNugetSource
- Add the source. The path “bin\MyLocalNugetSource” will be generated
in the subsequent step. Make sure to replace the path to the Godot
project root directory with the appropriate path on your local
machine. Note that the path must be an absolute path since relative
paths cannot be passed to the nuget source command:
dotnet nuget add source "D:\VisualStudios\godot\bin\MyLocalNugetSource" --name MyLocalNugetSource
- To verify that the nuget source was added correctly and is pointing
to the intended path, execute the following command:
dotnet nuget list source
- Generate the MyLocalNugetSource. After completing this step, the MyLocalNugetSource will be placed in the bin directory of the current directory.
python ./modules/mono/build_scripts/build_assemblies.py --godot-output-dir ./bin --push-nupkgs-local bin/MyLocalNugetSource
Now, you can run the editor and click “build” or “run” again to confirm that everything is functioning properly.
I have created a batch script to automate this process, assume the bug is fixed. Here is the script. Please save it as mono-compile.bat
in the Godot source code directory you have cloned.
@echo off
setlocal enabledelayedexpansion
@echo Compiling with .NET ...
scons dev_build=yes dev_mode=yes vsproj=yes module_mono_enabled=yes
@echo Generate glue sources ...
./bin/godot.windows.editor.dev.x86_64.mono.exe --headless --generate-mono-glue modules/mono/glue
@echo Build .NET assemblies ...
python ./modules/mono/build_scripts/build_assemblies.py --godot-output-dir=./bin --godot-platform=windows
set "sourceName=MyLocalNugetSource"
set "expectedPath=%cd%\bin\MyLocalNugetSource"
set "found=false"
for /f "tokens=2" %%A in ('dotnet nuget list source') do (
set "source=%%A"
if "!source!"=="%sourceName%" (
set "found=true"
)
)
@echo Make sure nuget source is clean.
if "%found%"=="true" (
dotnet nuget remove source MyLocalNugetSource
) else (
echo The NuGet source "%sourceName%" does not exist, ignore this step.
)
@echo add source path ...
dotnet nuget add source "%expectedPath%" --name MyLocalNugetSource
@echo Generate MyLocalNugetSource.
python ./modules/mono/build_scripts/build_assemblies.py --godot-output-dir ./bin --push-nupkgs-local bin/MyLocalNugetSource