xamarin-macios/tests/dotnet
Chris Hamons ab5c0c6b56
[net6] Fix ILStrip'ed apps to actually work again (#13098)
* [net6] Fix ILStrip'ed apps to actually work again

- In a late minute change to the ILStrip PR (https://github.com/xamarin/xamarin-macios/pull/12563) a change to support XVS support broke execution of Apps that were stripped
- Applications were broken because none of the stripped assemblies were actually copied into the bundle
- However, the tests still passed, because all assemblies that were there had no IL (zero assemblies total)

Now why did this happen?
- The stripped assemblies were changed to return via an msbuild Output Element
- Output Element can return an Property or ItemGroup, depending if you use the PropertyName or ItemName attributes
- Unfortunately I used PropertyName, when I expected an ItemGroup. So I silently had a property created instead.
- Thus zero items were added to the list of files to copy into the bundle
- Which was undetected as the test did not confirm files were copied in, and manual tests were not run so late into the PR (3 weeks after PR was opened)

How was it fixed?
- Correctly using ItemName on Output created a valid item group to reference
- However, that still failed with an absurdly confusing error:

 PATH/Microsoft.NET.Publish.targets(277,5): error MSB3024: Could not copy the file FILE to the destination file PATH, because the destination is a folder instead of a file. To copy the source file into a folder, consider using the DestinationFolder parameter instead of DestinationFiles.

- After a splunking through netcore targets, I found the metadata on these assemblies references really matters. Without it, they are not processed correctly at all.
- Thus, I updated ILStripBase to clone the existing metadata when changing the original assembly reference to the stripped path
- Finally, I corrected the test to assert that required files are copied in. I also manually ran our device test.

Co-authored-by: Rolf Bjarne Kvinge <rolf@xamarin.com>
2021-10-25 11:31:42 -05:00
..
AppWithResources [msbuild/dotnet] Compile project-level assets in the outer build for multi-rid builds. Fixes #12410. (#12847) 2021-09-30 08:25:10 +02:00
BindingWithDefaultCompileInclude [dotnet] Enable default compile items for binding projects. Fixes #12532. (#12758) 2021-09-20 13:41:20 +02:00
ExtensionConsumer [net6][msbuild] Set SelfContained for AppExtensions sooner to fix publishing (#12703) 2021-09-20 09:40:41 -05:00
ExtensionProject [tests] Bump our generic min macOS version to 10.14 for .NET tests. (#12938) 2021-10-07 09:09:46 +02:00
MyCatalystApp [dotnet] Support SupportedOSPlatformVersion. Fixes #12336. (#12638) 2021-09-08 09:20:05 +02:00
MyClassLibrary [dotnet] Add support for 'dotnet pack'. Fixes #12631. (#12900) 2021-10-04 07:43:55 +02:00
MyCocoaApp [dotnet] Support SupportedOSPlatformVersion. Fixes #12336. (#12638) 2021-09-08 09:20:05 +02:00
MyInterpretedApp [msbuild] Don't require an Info.plist for .NET builds. (#12661) 2021-09-09 09:08:04 +02:00
MyPartialAppManifestApp [msbuild] Don't require an Info.plist for .NET builds. (#12661) 2021-09-09 09:08:04 +02:00
MySimpleApp [msbuild] Don't require an Info.plist for .NET builds. (#12661) 2021-09-09 09:08:04 +02:00
MySingleView [dotnet] Support SupportedOSPlatformVersion. Fixes #12336. (#12638) 2021-09-08 09:20:05 +02:00
MyTVApp [dotnet] Support SupportedOSPlatformVersion. Fixes #12336. (#12638) 2021-09-08 09:20:05 +02:00
MyXamarinFormsApp [dotnet] Support SupportedOSPlatformVersion. Fixes #12336. (#12638) 2021-09-08 09:20:05 +02:00
NativeDynamicLibraryReferencesApp [msbuild] Don't require an Info.plist for .NET builds. (#12661) 2021-09-09 09:08:04 +02:00
NativeFileReferencesApp [msbuild] Don't require an Info.plist for .NET builds. (#12661) 2021-09-09 09:08:04 +02:00
NativeFrameworkReferencesApp [msbuild] Don't require an Info.plist for .NET builds. (#12661) 2021-09-09 09:08:04 +02:00
NativeXCFrameworkReferencesApp [msbuild] Don't require an Info.plist for .NET builds. (#12661) 2021-09-09 09:08:04 +02:00
SimpleAppWithOldReferences [msbuild] Don't require an Info.plist for .NET builds. (#12661) 2021-09-09 09:08:04 +02:00
UnitTests [net6] Fix ILStrip'ed apps to actually work again (#13098) 2021-10-25 11:31:42 -05:00
size-comparison/MySingleView [dotnet] Support SupportedOSPlatformVersion. Fixes #12336. (#12638) 2021-09-08 09:20:05 +02:00
.gitignore [tests][dotnet] A few helping touch to do size comparison (#11446) 2021-05-05 19:15:18 -04:00
Makefile [msbuild] Add ILStrip'ing for net6 applications. Fixes #11445. (#12563) 2021-10-05 09:43:22 -05:00
README.md [msbuild] Add ILStrip'ing for net6 applications. Fixes #11445. (#12563) 2021-10-05 09:43:22 -05:00

README.md

.net tests

size-comparison

Easier Analysis

If you want to read/compare the IL inside the assemblies you need to disable IL stripping.

  • Legacy (oldnet)

Add this option inside the Release|iPhone configuration of size-comparison/MySingleView/oldnet/MySingleView.csproj

<MtouchExtraArgs>--nostrip</MtouchExtraArgs>
  • net6

Build with /p:EnableAssemblyILStripping=false set. The MtouchExtraArgs legacy option is also honored.