Protecting Xamarin Apps
These instructions will walk you through how to get started using Dotfuscator Professional to protect a Xamarin project. After you're done, the protection process will be integrated into your project, so whenever you build the project in Visual Studio or MSBuild, Dotfuscator will automatically protect it. You can integrate Dotfuscator into each platform your app supports, creating an app with a proven, layered protection strategy, no matter what device it's running on.
Dotfuscator integrates with Xamarin applications as part of the regular Xamarin build process, using the same approach used by other .NET platforms. However, there are some unique aspects to the Xamarin integration that you should understand before you begin. The following diagrams give a broad overview of the various platforms in a Xamarin solution.
For a Xamarin Android project, Dotfuscator will insert itself into the build after compiling the MSIL and before the Xamarin Android apk packaging step.
An iOS build is slightly more complex. The C# compiler and Dotfuscator will run on Windows followed by the Xamarin iOS packaging step which will run remotely on a Mac OS computer.
A Xamarin UWP project is structurally very similar to a Xamarin Android project. Dotfuscator will inject itself before the appx packaging step.
Note: The Dotfuscator-Xamarin integration has been designed to work on Android, iOS, and the Universal Windows Platform (UWP). Other platforms, particularly Windows 8.x platforms, are not supported.
Dotfuscator should be integrated into the output project for each target platform in the solution. As shown in the diagrams above, Dotfuscator's position in the build process is slightly different for each platform, and Dotfuscator sometimes needs to have unique configuration settings for each platform (e.g. Root Checks on Android, or a renaming exclusion that is only necessary on iOS).
Dotfuscator only needs to be integrated into output projects that produce mobile app packages, such as an Android project that produces an APK. When Dotfuscator protects these output projects, it will also automatically protect all assemblies packaged as part of that project. You do not need to integrate Dotfuscator into library projects, such as NET Standard Libraries or Portable Class Libraries (PCL), that are used by the output projects because they are automatically protected. For more information see Choosing Which Projects to Protect.
For each output project you integrate Dotfuscator into, you also need to decide what build configurations you want the protection applied to. The default configuration provided in the instructions will protect Release, Ad-Hoc, and AppStore configurations. The Ad-Hoc and AppStore configurations are only used by iOS projects. For more information, see Choosing Which Configurations to Protect
To get started, follow the instructions on the Protect Your App page for one of your target platforms. Then repeat that process for each additional platform you wish to protect.
What happened to the 'PreEmptive.Dotfuscator.Xamarin.targets' file?
Dotfuscator's Xamarin integration has improved dramatically since it was first introduced.
The initial integration method required you to download a
PreEmptive.Dotfuscator.Xamarin.targets file, and some external documentation and blog posts might still direct you to do so.
However, as of Dotfuscator Professional v4.37, that is no longer necessary, and the integration is much easier to use.
Please follow the appropriate instructions for your version of Dotfuscator: