xamarin-macios/dotnet
Ivan Povazan 5633f4e890
NativeAOT: Fix output dir path for universal apps built with NativeAOT (#21288)
### Description 

When building universal apps with NativeAOT, the output path for the app bundle (and zipped .ipa) is incorrect when building with NativeAOT.

For example publishing a MAUI template app with NativeAOT gives the following output (notice: `osx-arm64`):
```
Created the package: /Users/ivan/tmp/net9-rc1/MacCatRc1/bin/Release/net9.0-maccatalyst/osx-arm64/publish/MacCatRc1-1.0.pkg
```
and the following output tree:
```
bin/Release 
bin/Release/net9.0-maccatalyst 
bin/Release/net9.0-maccatalyst/maccatalyst-arm64/*
bin/Release/net9.0-maccatalyst/maccatalyst-x64/*
bin/Release/net9.0-maccatalyst/osx-arm64
bin/Release/net9.0-maccatalyst/osx-arm64/MacCatRc1.app/*
bin/Release/net9.0-maccatalyst/osx-arm64/publish/*
```

The problem comes from the fact that .NET SDK for NativeAOT builds will try to resolve `RuntimeIdentifier` when it is not specified in:
58eb155e30/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.RuntimeIdentifierInference.targets (L95-L114)

which resolves to `osx-arm64` and gets later used to setup `IntermediateOutputPath` and `OutputPath` in:
58eb155e30/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.RuntimeIdentifierInference.targets (L343-L346)
 
However, this shouldn't be done in universal builds, as the outer build does not have the runtime identifier specified and should not be altered.

### Changes

In this PR we are disabling the resolution of the `RuntimeIdentifier` when building universal apps with NativeAOT early in SDK in order to fix the output path.

I also included unit tests to verify the existence of .app bundles. 

### Follow-up

There is an additional issue with Debug builds of universal apps with NativeAOT, where merging PDBs fails, which is reported in: https://github.com/xamarin/xamarin-macios/issues/20903

---
Contributes to: https://github.com/xamarin/xamarin-macios/issues/20903

---------

Co-authored-by: Ivan Povazan <ivan.povazan@gmail.com>
2024-09-23 21:18:12 +02:00
..
Microsoft.MacCatalyst.Sdk [net9.0] Remove xcsync from SDK and install as .NET Global Tool (#21126) 2024-08-28 07:52:58 -04:00
Microsoft.iOS.Sdk [net9.0] Remove xcsync from SDK and install as .NET Global Tool (#21126) 2024-08-28 07:52:58 -04:00
Microsoft.iOS.Windows.Sdk
Microsoft.macOS.Sdk [net9.0] Remove xcsync from SDK and install as .NET Global Tool (#21126) 2024-08-28 07:52:58 -04:00
Microsoft.tvOS.Sdk [net9.0] Remove xcsync from SDK and install as .NET Global Tool (#21126) 2024-08-28 07:52:58 -04:00
Templates Merge remote-tracking branch 'origin/main' into dev/rolf/bump-main-in-net9.0-2024-09-18 2024-09-19 09:48:34 +02:00
Workloads [net9.0] Remove xcsync from SDK and install as .NET Global Tool (#21126) 2024-08-28 07:52:58 -04:00
package [build] Make package metadata optional (#21081) 2024-08-23 12:19:32 -04:00
targets NativeAOT: Fix output dir path for universal apps built with NativeAOT (#21288) 2024-09-23 21:18:12 +02:00
.gitignore
BreakingChanges.md
BundleContents.md
DefaultCompilationIncludes.md
HIERARCHY.md
Makefile [net9.0] Merge main into net9.0. 2024-09-04 15:24:51 +02:00
PackageInfo.plist
SingleProject.md
VERSIONS.md [build] Make package metadata optional (#21081) 2024-08-23 12:19:32 -04:00
build-custom-runtime.sh
generate-target-platforms.csharp
generate-vs-workload.csharp
generate-wix.csharp
generate-workloadmanifest-json.csharp
generate-workloadmanifest-targets.csharp