Closed Petrarca181 closed 11 months ago
What platform are you targeting here?
2 enable aot
What does this mean? AOT is already enabled in Release
mode for mobile, for example.
Unfortunately, just saying "AOT" isn't specific enough. Is it Mono AOT or NativeAOT? Thanks!
Hi @Petrarca181. We have added the "s/needs-info" label to this issue, which indicates that we have an open question for you before we can take further action. This issue will be closed automatically in 7 days if we do not hear back from you by then - please feel free to re-open it if you come back to this issue after that time.
What platform are you targeting here?
2 enable aot
What does this mean? AOT is already enabled in
Release
mode for mobile, for example.Unfortunately, just saying "AOT" isn't specific enough. Is it Mono AOT or NativeAOT? Thanks!
Ok now I see, I have two AOT checkboxes. I was speaking about this one .
I am facing the same issue when trying to enable NativeAOT (via PublishAot = true
) for Android target on any .NET MAUI projects, even the default template.
I tried it both on macOS M1 and Windows x64 using dotnet 8.0.100.
To reproduce:
dotnet new maui -n AndroidNativeAotError
AndroidNativeAotError.csproj
and add the following
<PropertyGroup Condition="'$(Configuration)' == 'Release'">
<PublishAot>true</PublishAot>
</PropertyGroup>
dotnet publish -f net8.0-android -c Release /p:AndroidSigningKeyStore=(...) /p:AndroidSigningStorePass=(...) /p:AndroidSigningKeyAlias=(...) /p:AndroidSigningKeyPass=(...)
dotnet publish
should fail with
MSBuild version 17.8.3+195e7f5a3 for .NET
Determining projects to restore...
/Users/username/Git/Tests/AndroidNativeAot/AndroidNativeAot.csproj : error NU1101: Unable to find package runtime.linux-arm.Microsoft.DotNet.ILCompiler. No packages exist with this id in source(s): /usr/local/share/dotnet/library-packs, nuget.org
Failed to restore /Users/username/Git/Tests/AndroidNativeAot/AndroidNativeAot.csproj (in 879 ms).
Note that publishing for net8.0-ios
works well.
Full logs for dotnet publish logs.txt
I checked a little bit the MSBuild logs and noticed the android-arm
workload tries to resolve this non-existing runtime.linux-arm.Microsoft.DotNet.ILCompiler
.
I thought this was because the RuntimeIdentifier android-arm
is buggy, so I switched to <RuntimeIdentifier>android-arm64</RuntimeIdentifier>
, but now I get a different error.
MSBuild version 17.8.3+195e7f5a3 for .NET
Determining projects to restore...
All projects are up-to-date for restore.
AndroidNativeAot -> /Users/username/Git/Tests/AndroidNativeAot/bin/Release/net8.0-android/android-arm64/AndroidNativeAot.dll
/Users/username/.nuget/packages/microsoft.dotnet.ilcompiler/8.0.0/build/Microsoft.NETCore.Native.Publish.targets(76,5): error : The PrivateSdkAssemblies ItemGroup is required for _ComputeAssembliesToCompileToNative [/Users/username/Git/Tests/AndroidNativeAot/AndroidNativeAot.csproj::TargetFramework=net8.0-android]
Full logs logs.txt
This seems to be coming from here: https://github.com/dotnet/runtime/blob/e440ebc55895c80fced3410b8018dee79eb2ce4a/src/coreclr/nativeaot/BuildIntegration/Microsoft.NETCore.Native.Publish.targets#L74
I got no idea what it does but setting
<PublishAotUsingRuntimePack>true</PublishAotUsingRuntimePack>
gives you
Microsoft.NETCore.Native.Unix.targets(226,5): error : Symbol stripping tool ('llvm-objcopy' or 'objcopy') not found in PATH. Try installing appropriate package for llvm-objcopy or objcopy to resolve the problem or set the StripSymbols property to false to disable symbol stripping.
And then setting
<StripSymbols>false</StripSymbols>
gives you
Unhandled Exception: System.CommandLine.CommandLineException: Target OS 'android' is not supported
at System.CommandLine.Helpers.GetTargetOS(String) + 0x684
at System.CommandLine.CliArgument`1.<>c__DisplayClass8_0.<set_CustomParser>b__0(ArgumentResult argumentResult, Object& parsedValue) + 0x44
at System.CommandLine.Parsing.ArgumentResult.ValidateAndConvert(Boolean) + 0x2ec
at System.CommandLine.Parsing.CommandResult.ValidateOptions(Boolean) + 0x3cc
at System.CommandLine.Parsing.CommandResult.Validate(Boolean) + 0x2b4
at System.CommandLine.Parsing.ParseOperation.Validate() + 0x20
at System.CommandLine.Parsing.ParseOperation.Parse() + 0x38
at System.CommandLine.Parsing.CliParser.Parse(CliCommand, IReadOnlyList`1, String, CliConfiguration) + 0x8c
at System.CommandLine.CliConfiguration.Invoke(String[]) + 0x1c
at ilc!<BaseAddress>+0x6e6448
Microsoft.NETCore.Native.targets(305,5): error MSB3073: The command ""/Users/mlach/.nuget/packages/runtime.osx-arm64.microsoft.dotnet.ilcompiler/8.0.0/tools/ilc" @"obj/Release/net8.0-android/android-arm64/native/FE.Mobile.ilc.rsp"" exited with code 134.
No idea what this all means.
Does the native AOT compilation have any machine type restrictions? Does only work on windows x64 or will it work on any type? FYI I tried all of the above on an M1 mac.
For my side, what I found is when you add this to your project:
To be clear, NativeAOT is not yet supported on Android -- that is the cause of the various errors above.
It will be a long road, but the beginning of this work is happening at:
We are just getting started with NativeAOT on Android. It may not even be available when .NET 9 ships, we don't actually know yet.
For now, I would only try to use NativeAOT on iOS, which is also experimental. If you find issues using it, you can file them here:
Hope that helps! But I think we can close this as duplicate of our other ongoing NativeAOT work.
Description
Can't install Microsoft.DotNet.ILCompiler at all. Getting ths error in my Maui project: Unable to find package runtime.linux-arm.Microsoft.DotNet.ILCompiler.
Steps to Reproduce
1 Create Fresh maui app 2 enable aot 3build
Link to public reproduction project repository
No response
Version with bug
8.0.3
Is this a regression from previous behavior?
Not sure, did not test other versions
Last version that worked well
Unknown/Other
Affected platforms
Android
Affected platform versions
No response
Did you find any workaround?
no
Relevant log output
No response