Skip to content

Commit f0c9253

Browse files
committed
[.NET] Require net9.0 for Android exports
To ensure Android exports are compatible with the new Play Store requirement that all `.so` libraries included are aligned to 16k, we now require C# projects to target `net9.0` which uses the correct alignment (as opposed to the current one of 4k). The thirdparty jar library has also been updated to the one from the 9.0.4 runtime package so it's compatible with non-gradle builds targeting `net9.0`. Non-android projects are not affect, the minimum TFM is still `net8.0`.
1 parent 6c9aa4c commit f0c9253

File tree

4 files changed

+9
-3
lines changed

4 files changed

+9
-3
lines changed

modules/mono/editor/GodotTools/GodotTools.ProjectEditor/ProjectGenerator.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@ public static ProjectRootElement GenGameProject(string name)
2626
var mainGroup = root.AddPropertyGroup();
2727
mainGroup.AddProperty("TargetFramework", GodotMinimumRequiredTfm);
2828

29+
// Non-gradle builds require .NET 9 to match the jar libraries included in the export template.
30+
var net9 = mainGroup.AddProperty("TargetFramework", "net9.0");
31+
net9.Condition = " '$(GodotTargetPlatform)' == 'android' ";
32+
2933
mainGroup.AddProperty("EnableDynamicLoading", "true");
3034

3135
string sanitizedName = IdentifierUtils.SanitizeQualifiedIdentifier(name, allowEmptyIdentifiers: true);
Binary file not shown.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
https://www.nuget.org/packages/Microsoft.NETCore.App.Runtime.Mono.android-arm64/9.0.4

platform/android/export/export_plugin.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2739,6 +2739,7 @@ bool _validate_dotnet_tfm(const String &required_tfm, String &r_error) {
27392739
List<String> args;
27402740
args.push_back("build");
27412741
args.push_back(project_path);
2742+
args.push_back("/p:GodotTargetPlatform=android");
27422743
args.push_back("--getProperty:TargetFramework");
27432744

27442745
int exitcode;
@@ -2778,9 +2779,9 @@ bool EditorExportPlatformAndroid::has_valid_export_configuration(const Ref<Edito
27782779
err += TTR("Exporting to Android when using C#/.NET is experimental.") + "\n";
27792780

27802781
if (!gradle_build_enabled) {
2781-
// For template exports we only support .NET 8 because the template
2782-
// includes .jar dependencies that may only be compatible with .NET 8.
2783-
if (!_validate_dotnet_tfm("net8.0", err)) {
2782+
// For template exports we only support .NET 9 because the template
2783+
// includes .jar dependencies that may only be compatible with .NET 9.
2784+
if (!_validate_dotnet_tfm("net9.0", err)) {
27842785
r_error = err;
27852786
return false;
27862787
}

0 commit comments

Comments
 (0)