Forum Xamarin.iOS

Running post-build operation on assemblies in bundle


I'd like to run an obfuscation step (using ConfuserEx) on my .NET assemblies before/after they are placed into the .app package. Suppose I have two assemblies: A.dll (a portable class library) and MyApp.exe. I see that after building, both of these files are located in Can I just run a post-build step that calls the obfuscator on those files? Or is there something more subtle I need to do to make sure that the assemblies that get placed in the release bundle are obfuscated?


  • ChrisHamonsChrisHamons USForum Administrator, Xamarin Team Xamurai

    If you want to run operations post build pre-signing, use this sample as a guide:

    I believe if you do not use AOT on your assemblies then it should be relatively safe (never tested it but seems reasonable).

  • TylerDennistonTylerDenniston USMember ✭✭

    Thanks, this looks great. I don't think I can use AOT because I have the community edition of VS.

  • ChrisHamonsChrisHamons USForum Administrator, Xamarin Team Xamurai

    AOT (along with almost every single XM feature I can think of outside of profiling) is not restricted by license.

    The IDE support is not great but you can read about AOT here:

    Here is the final feature commit:

    but the command line argument is changed to:

      --aot[=VALUE]          Specify assemblies that should be experimentally
                               AOT compiled
                               - none - No AOT (default)
                               - all - Every assembly in MonoBundle
                               - core - Xamarin.Mac, System, mscorlib
                               - sdk - Xamarin.Mac.dll and BCL assemblies
                               - |hybrid after option enables hybrid AOT which
                               allows IL stripping but is slower
                                - Individual files can be included for AOT via +
                               FileName.dll and excluded via -FileName.dll
  • TylerDennistonTylerDenniston USMember ✭✭

    That's great, thank you for clarifying! Is AOT still considered experimental? The flag was renamed but there is still the word "experimentally" in the usage docs you posted.

  • ChrisHamonsChrisHamons USForum Administrator, Xamarin Team Xamurai

    Not really, we haven't found any major issues, it is just noted that way because it is a new feature.

    I'll make a note to remove that at some point.

  • TylerDennistonTylerDenniston USMember ✭✭

    Is there more documentation available somewhere on this? I'd like to know more about how it works. For example, I don't understand why I need both *.dll and *.dylib files in the MonoBundle -- it seems like you should only need the dylibs. Additionally, I ran with one of the examples given (--aot:core|hybrid,+MyLib.dll) and the build failed with this error: MMP : error MM0114: Hybrid AOT compilation requires all assemblies to be AOT compiled. This is probably just because I don't know what I'm doing.

  • ChrisHamonsChrisHamons USForum Administrator, Xamarin Team Xamurai

    Unfortunately not right now (beyond asking me). Adding full fledged documentation and IDE support has been on my backlog for awhile.

    • If you want to take a peek "under the hood", the relevant code lives here (
    • If you enable AOT after assemblies are copied in we invoke the mono compiler, asking it to AOT compile each assembly while resolving to only assemblies also found inside the MonoBundle.
    • This creates dylib files next to each managed assembly (.dll) with the generated code
    • However, the managed assembly is still needed. There are some things, such as generics, which AOT produces significantly worse/larger code than JIT. By keeping the managed assembly around, we can JIT just those things as we need.
    • If you desire the ability to remove the managed assemblies completely, the hybrid option "forces" the issue by AOTing even those parts. You will be slower in some corner cases though.
    • It was found out late in development that the hybrid option only provides reasonable results if you AOT all assemblies in question. Thus, core|hybrid,+MyLib.dll errors out.
    • The doc string is incorrect in suggesting this should work (also noted in
    • If you want to use hybrid try --aot:all|hybrid
Sign In or Register to comment.