godotengine / godotengine/godot-dotnet
UpgradeAssistant wrongly attempts to re-upgrade an already up-to-date .csproj and crashes
- Dominant language
- C#
- Stars
- 228
- Forks
- 30
- PR merge metrics
- No merged PRs in 30d
Description
### Godot version
4.6.dev (1a79957f6b2fb0df13e8a8ca342a8eba8d6cf7bc) from https://github.com/raulsntos/godot/tree/new-dotnet-module-plus-source-code-plugin-wip
### Godot .NET packages version
4.6.0-dev (167e71bf253de4bec29e3df0b513d39356f4a642) from https://github.com/raulsntos/godot/tree/new-dotnet-module-plus-source-code-plugin-wip
### System information
Fedora 42
### .NET information
dotnet 9.0.9 from Fedora 42, SDKs 8.0.120 and 9.0.110
### Issue description
Yesterday I successfully created a .NET project using the editor integration.
The second time I opened the same project, I got an error that it couldn't upgrade the project (didn't copy it).
Today, opening the same project for the 3rd time with the same build, I get a crash on start because it tries to upgrade an already upgraded `.csproj` file:
```
Unhandled exception: System.MissingMethodException: Method not found: 'System.Collections.Immutable.ImmutableArray`1 NuGet.ProjectModel.TargetFrameworkInformation.get_Dependencies()'.
at Godot.UpgradeAssistant.Providers.DotNetProjectReferencesAnalysisProvider.GetTopLevelPackageReferences(String targetFrameworkMoniker, LockFile assetsFile)
at Godot.UpgradeAssistant.Providers.DotNetProjectReferencesAnalysisProvider.AnalyzeAsync(AnalysisContext context, CancellationToken cancellationToken) in /home/akien/Godot/godot-dotnet/src/Godot.UpgradeAssistant.Providers/AnalysisProviders/DotNetProjectReferencesAnalysisProvider.cs:line 73
at Godot.UpgradeAssistant.AnalyzeStep.RunAsync(CancellationToken cancellationToken) in /home/akien/Godot/godot-dotnet/src/Godot.UpgradeAssistant.Core/Steps/AnalyzeStep.cs:line 85
at Godot.UpgradeAssistant.AnalyzeStep.RunAndGetResultsAsync(CancellationToken cancellationToken) in /home/akien/Godot/godot-dotnet/src/Godot.UpgradeAssistant.Core/Steps/AnalyzeStep.cs:line 98
at Godot.UpgradeAssistant.Cli.Services.UpgradeService.RunAsync(UpgradeServiceConfiguration configuration, CancellationToken cancellationToken) in /home/akien/Godot/godot-dotnet/src/Godot.UpgradeAssistant.Cli/Services/UpgradeService.cs:line 88
at Godot.UpgradeAssistant.Cli.Commands.UpgradeCommand.HandleInvocationAsync(IHost host, AssistantCommandOptions options, CancellationToken cancellationToken) in /home/akien/Godot/godot-dotnet/src/Godot.UpgradeAssistant.Cli/Commands/UpgradeCommand.cs:line 16
at Godot.UpgradeAssistant.Cli.Commands.AssistantCommandBase.HandleCommand(ParseResult parseResult, CancellationToken cancellationToken) in /home/akien/Godot/godot-dotnet/src/Godot.UpgradeAssistant.Cli/Commands/AssistantCommandBase.cs:line 179
at System.CommandLine.Invocation.InvocationPipeline.InvokeAsync(ParseResult parseResult, CancellationToken cancellationToken)
ERROR: .NET failed to upgrade project 'NewDotnet2'. See output above for more details.
at: Upgrade (/home/akien/Godot/godot-dotnet/src/Godot.EditorIntegration/UpgradeAssistant/GodotUpgradeAssistant.cs:442)
ERROR: Trying to unreference a SafeRefCount which is already zero is wrong and a symptom of it being misused.
Upon a SafeRefCount reaching zero any object whose lifetime is tied to it, as well as the ref count itself, must be destroyed.
Moreover, to guarantee that, no multiple threads should be racing to do the final unreferencing to zero.
at: _check_unref_safety (./core/templates/safe_refcount.h:186)
ERROR: Caller thread can't call this function in this node (/root). Use call_deferred() or call_thread_group() instead.
at: propagate_notification (./scene/main/node.cpp:2610)
================================================================
handle_crash: Program crashed with signal 4
Engine version: Godot Engine v4.6.dev.dotnet.custom_build (1a79957f6b2fb0df13e8a8ca342a8eba8d6cf7bc)
Dumping the backtrace. Please include this when reporting the bug on: https://github.com/godotengine/godot/issues
[1] /usr/lib64/dotnet/shared/Microsoft.NETCore.App/9.0.9/libcoreclr.so(+0x66f770) [0x7ff976e6f770] (??:0)
[2] /lib64/libc.so.6(+0x1a070) [0x7ffa41822070] (??:0)
[3] StringName::unref() (/home/akien/Godot/godot/core/templates/safe_refcount.h:186 (discriminator 5))
[4] StringName::~StringName() (/home/akien/Godot/godot/core/string/string_name.h:185)
[5] VariantDestruct::ptr_destruct(void*) (/home/akien/Godot/godot/core/variant/variant_destruct.h:52)
[6] [0x7ff8f92fe429] (??:0)
-- END OF C++ BACKTRACE --
================================================================
Aborted (core dumped)
```
The editor still opens anyway, so I assume the upgrade is done via a separate process which is crashing.
```
$ cat godot-dotnet-upgrade-assistant.log.clef
{"@t":"2025-10-22T19:48:56.6664632Z","@mt":"Upgrading project '/home/akien/new-dotnet-2/project.godot' to Godot 4.6.0-dev."}
{"@t":"2025-10-23T09:58:28.4930941Z","@mt":"Upgrading project '/home/akien/new-dotnet-2/project.godot' to Godot 4.6.0-dev."}
{"@t":"2025-10-23T10:04:25.5063905Z","@mt":"Upgrading project '/home/akien/new-dotnet-2/project.godot' to Godot 4.6.0-dev."}
```
### Steps to reproduce
Hard to say, because creating a new project from scratch currently segfaults when trying to create a new extension class.
### Minimal reproduction project
[new-dotnet-2.zip](https://github.com/user-attachments/files/23095329/new-dotnet-2.zip)
Contributor guide
Assessment
This issue has not been assessed yet.