Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

.NET Android export should validate that the TargetFramework is net7.0, and that only supported architectures are selected (i.e. x64 or arm64-v8a) #82013

Closed
BrainSlugs83 opened this issue Sep 20, 2023 · 6 comments · Fixed by #82762

Comments

@BrainSlugs83
Copy link

BrainSlugs83 commented Sep 20, 2023

Godot version

v4.2-dev5_mono_win64 (and 4.2-dev4_mono_win64)

System information

Godot v4.2.dev5.mono - Windows 10.0.22621 - Vulkan (Forward+) - dedicated NVIDIA GeForce RTX 2070 with Max-Q Design (NVIDIA; 31.0.15.3161) - Intel(R) Core(TM) i7-10750H CPU @ 2.60GHz (12 Threads)

Issue description

Android export fails because of a non-existent NuGet package that can't be restored:
image

Manually trying to add this package to my project reports that the closest version available is 7.0.0, and that the platform is incompatible with the generated csproj file.

dotnet add package Microsoft.NETCore.App.Runtime.linux-bionic-x64 --version 6.0.21
  Determining projects to restore...
  Writing C:\Users\Mikey\AppData\Local\Temp\tmp1057.tmp
info : X.509 certificate chain validation will use the default trust store selected by .NET for code signing.
info : X.509 certificate chain validation will use the default trust store selected by .NET for timestamping.
info : Adding PackageReference for package 'Microsoft.NETCore.App.Runtime.linux-bionic-x64' into project 'C:\Projects.temp\Project1\Project1.csproj'.
info : Restoring packages for C:\Projects.temp\Project1\Project1.csproj...
info :   CACHE https://api.nuget.org/v3-flatcontainer/microsoft.netcore.app.runtime.linux-bionic-x64/index.json
warn : NU1603: Project1 depends on Microsoft.NETCore.App.Runtime.linux-bionic-x64 (>= 6.0.21) but Microsoft.NETCore.App.Runtime.linux-bionic-x64 6.0.21 was not found. An approximate best match of Microsoft.NETCore.App.Runtime.linux-bionic-x64 7.0.0 was resolved.
error: NU1213: The package Microsoft.NETCore.App.Runtime.linux-bionic-x64 7.0.0 has a package type DotnetPlatform that is incompatible with this project.
error: Package 'Microsoft.NETCore.App.Runtime.linux-bionic-x64' is incompatible with 'all' frameworks in project 'C:\Projects.temp\Project1\Project1.csproj'.

running dotnet --list-sdks reports that I have both 6.0 and 7.0 installed:

dotnet --list-sdks
6.0.317 [C:\Program Files\dotnet\sdk]
7.0.400 [C:\Program Files\dotnet\sdk]

Steps to reproduce

  1. On Windows 11 (yes I'm running 11 -- not 10 as the system info states) -- Download and run Godot 4.2-dev4 or 4.2-dev5, and create a new project.
  2. Create a simple scene with some CSG boxes, and a camera, attach a working C# script to one of the nodes.
  3. Generate the C# project files, and using visual studio 2022, add some code to the script.
  4. Attempt to export the APK using the automatically downloaded template.
  5. It fails with the above error about the missing nuget package and incompatible framework.

Minimal reproduction project

N/A

@akien-mga
Copy link
Member

As described in the release blog post, you should target .NET 7.0 for Android: https://godotengine.org/article/dev-snapshot-godot-4-2-dev-5/#downloads

@akien-mga
Copy link
Member

Well UX wise, I guess we should refuse to export if the TargetFramework is not net7.0.

@akien-mga akien-mga reopened this Sep 20, 2023
@akien-mga akien-mga changed the title Android .NET Support on 4.2-dev5 is still borked .NET Android export should validate that the TargetFramework is net7.0 Sep 20, 2023
@BrainSlugs83
Copy link
Author

As described in the release blog post, you should target .NET 7.0 for Android: https://godotengine.org/article/dev-snapshot-godot-4-2-dev-5/#downloads

  • Is that a choice that I have? -- Godot created the csproj and solution files. How do I chose what framework version to target? -- Just manually do it in Visual Studio, or is there an option in the Godot UX somewhere?

  • Also Perhaps when Godot creates the project files, it should create ones that target a version of .NET that it supports? 😕

@BrainSlugs83
Copy link
Author

BrainSlugs83 commented Sep 21, 2023

@akien-mga:

  • Additionally: Even after manually switching the csproj to .NET 7 target framework in Visual Studio, it still fails with the same error:
    image

Therefore, I believe the new title is wrong and should be reverted.

@BrainSlugs83 BrainSlugs83 changed the title .NET Android export should validate that the TargetFramework is net7.0 Android builds still do not work even when TargetFramework is net7.0 Sep 21, 2023
@raulsntos
Copy link
Member

Is that a choice that I have? -- Godot created the csproj and solution files. How do I chose what framework version to target? -- Just manually do it in Visual Studio, or is there an option in the Godot UX somewhere?

Yes, you can change the <TargetFramework> to net7.0 in the csproj manually or using Visual Studio.

Also Perhaps when Godot creates the project files, it should create ones that target a version of .NET that it supports?

Only the current experimental Android support requires targeting .NET 7.0. We considered changing the project creation to default to .NET 7.0, but it can break in some scenarios (see #72333).

Additionally: Even after manually switching the csproj to .NET 7 target framework in Visual Studio, it still fails with the same error

The current experimental Android support only supports architectures arm64 and x64. You seem to be trying to build for architecture x86.

@BrainSlugs83
Copy link
Author

Alright, yeah removing arm64-v8a and x86 and setting .net7.0 fixed it.

The deploy build button doesn't work, but that's a different issue. -- The .apk builds, and I can deploy it via command line; so I think your original asssement is correct.

Though I would recommend two warnings in this case:

  • If the target framework is not net7.0.
  • If a non-supported architecture is selected (i.e. x86 or arm64-v8a -- or anything else other than the explicitly supported ones).

@BrainSlugs83 BrainSlugs83 changed the title Android builds still do not work even when TargetFramework is net7.0 .NET Android export should validate that the TargetFramework is net7.0, and that only supported architectures are selected (i.e. x64 or arm64-v8a) Sep 26, 2023
@akien-mga akien-mga added this to the 4.2 milestone Oct 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants