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

Cross-OS native compilation is not supported. #109284

Closed
akoc95 opened this issue Jul 27, 2024 · 6 comments
Closed

Cross-OS native compilation is not supported. #109284

akoc95 opened this issue Jul 27, 2024 · 6 comments

Comments

@akoc95
Copy link

akoc95 commented Jul 27, 2024

Description

It's a new project. No any changes.
Once I switch < PublishAot >true< /PublishAot > error below.

Severity Code Description Project File Line Suppression State
Error (active) Cross-OS native compilation is not supported. MauiTestAot(net8.0-android) .nuget\packages\microsoft.dotnet.ilcompiler\8.0.7\build\Microsoft.NETCore.Native.Publish.targets 60

net8.0-android;
<OutputType>Exe</OutputType>
<RootNamespace>MauiApp1</RootNamespace>
<UseMaui>true</UseMaui>
<SingleProject>true</SingleProject>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<RuntimeIdentifier>android-arm64</RuntimeIdentifier>
<PublishAot>true</PublishAot>
<!-- Display name -->
<ApplicationTitle>MauiApp1</ApplicationTitle>

<!-- App Identifier -->
<ApplicationId>com.companyname.mauiapp1</ApplicationId>

<!-- Versions -->
<ApplicationDisplayVersion>1.0</ApplicationDisplayVersion>
<ApplicationVersion>1</ApplicationVersion>

<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'android'">28.0</SupportedOSPlatformVersion>

Steps to Reproduce

No response

Link to public reproduction project repository

No response

Version with bug

8.0.61 SR6.1

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







<ItemGroup>
  <_ResolvedCopyLocalPublishAssets Remove="@(_AssembliesToSkipPublish)" />
  <_ResolvedCopyLocalPublishAssets Include="@(_LinkedResolvedAssemblies)" />
</ItemGroup>

<ItemGroup>
  <_NativeIntermediateAssembly Include="@(IntermediateAssembly->'$(NativeOutputPath)%(Filename)$(NativeBinaryExt)')" />
  <IntermediateAssembly Remove="@(IntermediateAssembly)" />
  <IntermediateAssembly Include="@(_NativeIntermediateAssembly)" />
</ItemGroup>
<Warning Condition="Exists($(UserRuntimeConfig))" Text="The published project has a runtimeconfig.template.json that is not supported by PublishAot. Move the configuration to the project file using RuntimeHostConfigurationOption." />
<!-- Fail with descriptive error message for common mistake. -->
<Error Condition="$([MSBuild]::VersionLessThan('$(NETCoreSdkVersion)', '6.0.0'))" Text=".NET SDK 6+ is required for native compilation." />
<Error Condition="$([MSBuild]::VersionLessThan('$(TargetFrameworkVersion)', '6.0'))" Text="For native compilation, the project needs to target .NET 6 or higher." />
<Error Condition="'$(RuntimeIdentifier)' == ''"
  Text="RuntimeIdentifier is required for native compilation. Try running dotnet publish with the -r option value specified." />
<Error Condition="'$(GeneratePackageOnBuild)' == 'true'" Text="GeneratePackageOnBuild is not supported for native compilation." />
<Error Condition="'$(OutputType)' != 'Library' and '$(NativeLib)' != '' and '$(CustomNativeMain)' != 'true'" Text="NativeLib requires OutputType=Library." />
<Warning Condition="'$(NativeLib)' != '' and '$(EventSourceSupport)' == 'true' and '$(_SuppressNativeLibEventSourceWarning)' != 'true'" Text="EventSource is not supported or recommended when compiling to a native library. Please go to https://github.com/dotnet/runtime/issues/91762 for more details." />

<Error Condition="'$(PublishTrimmed)' == 'false'" Text="PublishTrimmed is implied by native compilation and cannot be disabled." />

<Error Condition="'$(PublishAot)' == 'true' and '$(PublishSingleFile)' == 'true'" Text="PublishAot and PublishSingleFile cannot be specified at the same time." />

<!-- Fail with descriptive error message for common unsupported cases. -->
<Error Condition="'$(DisableUnsupportedError)' != 'true' and '$(OS)' == 'Windows_NT' and '$(_targetOS)' != 'win'"
  Text="Cross-OS native compilation is not supported." />

<Error Condition="'$(DisableUnsupportedError)' != 'true' and '$(OS)' != 'Windows_NT' and '$(_targetOS)' == 'win'"
  Text="Cross-OS native compilation is not supported." />

<Error Condition="'$(DisableUnsupportedError)' != 'true' and '$(_targetArchitecture)' != 'x64' and '$(_targetArchitecture)' != 'arm64'"
  Text="Native compilation does not support targeting $(RuntimeIdentifier) yet." />

<Error Condition="'$(DisableUnsupportedError)' != 'true' and !('$(_hostArchitecture)' == 'x64' or '$(_hostArchitecture)' == 'arm64')"
  Text="Native compilation can run on x64 and arm64 hosts only." />

<Error Condition="'$(IlcHostPackagePath)' == '' and '$(RuntimePackagePath)' != '' and ('$(_hostArchitecture)' == 'x64' or '$(_hostArchitecture)' == 'arm64')"
  Text="Add a PackageReference for '$(_hostPackageName)' to allow cross-compilation for $(_targetArchitecture)" />

<!-- NativeAOT runtime pack assemblies need to be defined to avoid the default CoreCLR implementations being set as compiler inputs -->
<Error Condition="'@(PrivateSdkAssemblies)' == '' and '$(PublishAotUsingRuntimePack)' != 'true'" Text="The PrivateSdkAssemblies ItemGroup is required for _ComputeAssembliesToCompileToNative" />
<Error Condition="'@(FrameworkAssemblies)' == '' and '$(PublishAotUsingRuntimePack)' != 'true'" Text="The FrameworkAssemblies ItemGroup is required for _ComputeAssembliesToCompileToNative" />

<ComputeManagedAssembliesToCompileToNative
  Assemblies="@(_ResolvedCopyLocalPublishAssets)"
  DotNetAppHostExecutableName="$(_DotNetAppHostExecutableName)"
  DotNetHostFxrLibraryName="$(_DotNetHostFxrLibraryName)"
  DotNetHostPolicyLibraryName="$(_DotNetHostPolicyLibraryName)"
  SdkAssemblies="@(PrivateSdkAssemblies)"
  FrameworkAssemblies="@(FrameworkAssemblies)">

  <Output TaskParameter="ManagedAssemblies" ItemName="_ManagedResolvedAssembliesToPublish" />
  <Output TaskParameter="SatelliteAssemblies" ItemName="_SatelliteAssembliesToPublish" />
  <Output TaskParameter="AssembliesToSkipPublish" ItemName="_AssembliesToSkipPublish" />
</ComputeManagedAssembliesToCompileToNative>



<PropertyGroup>
  <_symbolExt Condition="'$(OS)' == 'Windows_NT'">$(NativeSymbolExt)</_symbolExt>
  <_symbolExt Condition="'$(OS)' != 'Windows_NT'">$(NativeBinaryExt)$(NativeSymbolExt)</_symbolExt>
  <_symbolSourcePath>$(NativeOutputPath)$(TargetName)$(_symbolExt)</_symbolSourcePath>
  <_symbolTargetPath>$(PublishDir)\$(TargetName)$(_symbolExt)</_symbolTargetPath>
  <!-- If the symbol is a dsym bundle, it's a folder not a file. -->
  <_symbolIsFile Condition="'$(NativeSymbolExt)' == '.dsym'">false</_symbolIsFile>
  <_symbolIsFile Condition="'$(_symbolIsFile)' == ''">true</_symbolIsFile>
</PropertyGroup>

<ItemGroup>
  <_symbolRecursivePath Include="$(NativeOutputPath)$(TargetName)$(_symbolExt)/**/*" />
</ItemGroup>

<!-- replace native symbol file if it exists. On Mac, the symbol path may be a folder-->
<Delete Files="$(_symbolTargetPath)" Condition="'$(_symbolIsFile)' == 'true' and Exists('$(_symbolTargetPath)')" />
<Copy SourceFiles="$(_symbolSourcePath)" DestinationFolder="$(PublishDir)"
  Condition="'$(_symbolIsFile)' == 'true' and Exists('$(_symbolSourcePath)')" />

<!-- Copy folder otherwise -->
<RemoveDir Directories="$(_symbolTargetPath)" Condition="'$(_symbolIsFile)' == 'false' and Exists('$(_symbolTargetPath)')" />
<Copy SourceFiles="@(_symbolRecursivePath)" DestinationFolder="$(_symbolTargetPath)/%(RecursiveDir)"
  Condition="'$(_symbolIsFile)' == 'false' and Exists('$(_symbolSourcePath)')" />
Copy link
Contributor

Hi I'm an AI powered bot that finds similar issues based off the issue title.

Please view the issues below to see if they solve your problem, and if the issue describes your problem please consider closing this one and thumbs upping the other issue to help us prioritize it. Thank you!

Open similar issues:

Closed similar issues:

Note: You can give me feedback by thumbs upping or thumbs downing this comment.

@RoiChen001
Copy link

I can repro this issue at Android platform on the latest 17.11.0 Preview 5.0 (8.0.61&8.0.70).

@jonathanpeppers
Copy link
Member

jonathanpeppers commented Oct 28, 2024

NativeAOT is not yet supported for Android (such as .NET MAUI applications). Java interop is not implemented.

You can use linux-bionic-* RIDs, but you would be limited to plain .NET APIs, unable to call Android or Java APIs.

For tracking .NET MAUI / NativeAOT support you can follow these:

I will transfer this issue to dotnet/runtime, in case they want to comment about the error:

Cross-OS native compilation is not supported.

It seems like if NativeAOT were supported for Android, we'd want builds to work on Windows, Mac, & Linux.

@jonathanpeppers jonathanpeppers transferred this issue from dotnet/maui Oct 28, 2024
@dotnet-issue-labeler dotnet-issue-labeler bot added the needs-area-label An area label is needed to ensure this gets routed to the appropriate area owners label Oct 28, 2024
@dotnet-policy-service dotnet-policy-service bot added the untriaged New issue has not been triaged by the area owner label Oct 28, 2024
@vcsjones vcsjones removed the needs-area-label An area label is needed to ensure this gets routed to the appropriate area owners label Oct 30, 2024
@sudharsan-narayanan
Copy link

@jonathanpeppers For WinUI 3, the AOT support will works in latest SDK version?

@jonathanpeppers
Copy link
Member

NativeAOT works on Windows and iOS right now.

"Mono AOT" works for Android, iOS, etc. if you haven't opted into NativeAOT.

@agocke
Copy link
Member

agocke commented Nov 21, 2024

It seems like if NativeAOT were supported for Android, we'd want builds to work on Windows, Mac, & Linux.

Assuming the necessary native bits are available for each of these platforms we'll make it work. I don't know offhand whether the Android native toolchain is installable on, say, Mac OS.

@agocke agocke closed this as completed Nov 21, 2024
@dotnet-policy-service dotnet-policy-service bot removed the untriaged New issue has not been triaged by the area owner label Nov 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: No status
Development

No branches or pull requests

7 participants