godotengine / godotengine/godot

Godot 4.4 sets TargetFramework to net8 when already set to higher (net9) by Directory.Build.props

Open
#103,545 1 comment 1 reaction 0 assignees View on GitHub
bug topic:dotnet topic:editor
Dominant language
C++
Stars
117k
Forks
26.8k
PR merge metrics
PR metrics pending

Description

### Tested versions

Repro: All versions 4.4 and greater.
No-Repro: All versions of 4.3 and lower.

### System information

Windows 10 - Godot Engine v4.4.stable.mono.official.4c311cbee

### Issue description

With the release of Godot 4.4, the minimum target platform was raised to net8 (hurray!), but the Editor's automatic csproj upgrade logic does NOT properly take into account the MSBuild environment in which the csproj file executes. When setting a global `` across an entire directory tree of projects through a `Directory.Build.props` (or other included props file) the property may not appear directly in a csproj file. The Editor, however, only looks locally within the csproj file textually (not semantically) and improperly inserts a `net8` tag causing a failure during the build. Even if this erroneous tag is removed, the Editor will continually reinsert it again whenever the project is loaded.

3 suggested possible fixes:
1. Have feature (e.g. property that can be set globally) that disables this upgrade logic when present.
2. Execute MSBuild to evaluate the csproj file to determine its current `TargetPlatform` semantically instead of parsing the csproj file textually - thus giving MSBuild full control of evaluation. Then only insert a tag IFF the resulting evaluation says the `TargetPlatform` is < the MinRequiredTargetPlatform.
3. Execute the upgrade logic AT MOST ONCE on each csproj file. During a Godot upgrade in the dev environment (e.g. from 4.3 to 4.4) execute the Editor's upgrade logic for the `TargetPlatform` only the first time the project is loaded (perhaps when its SDK entry is also upgraded) and NEVER again. This would allow manual deletion of the extra tag during the upgrade process with no long-term effects.

This behavior appears to have been introduced by [PR 100195](https://github.com/godotengine/godot/pull/100195).

### Steps to reproduce

Open a csproj that (implicitly) imports a `net9` tag from a props file.

### Minimal reproduction project (MRP)

N/A

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.