I'm developing a Xamarin.Forms app using Visual Studio for Mac (Community Edition). I'm able to decompile the source code of the Android application using ILSpy
In order to obfuscate the source code, I used Obfuscar and followed the steps in https://docs.obfuscar.com/tutorials/xamarin.html
obfuscar.xml
<Obfuscator>
<Var name="RenameProperties" value="true" />
<Var name="RenameEvents" value="true" />
<Var name="RenameFields" value="true" />
<Var name="KeepPublicApi" value="false" />
<Var name="HidePrivateApi" value="true" />
<Var name="HideStrings" value="true" />
<Var name="UseUnicodeNames" value="true" />
<Var name="OptimizeMethods" value="true" />
<Var name="InPath" value="./bin/Release" />
<Var name="OutPath" value="./bin/Release/Obfuscator_Output" />
<Module file="$(InPath)/Sample.dll" />
</Obfuscator>
When the project is built in the Release
mode, Archived, and Decompiled, the source code is still visible in plain text using ILSpy.
I need help in configuring Obfuscator correctly for the Xamarin.Forms project
Everything worked fine with the below Obfuscar configuration
<Obfuscator>
<Var name="RenameProperties" value="true" />
<Var name="RenameEvents" value="true" />
<Var name="RenameFields" value="true" />
<Var name="KeepPublicApi" value="false" />
<Var name="HidePrivateApi" value="true" />
<Var name="HideStrings" value="true" />
<Var name="UseUnicodeNames" value="true" />
<Var name="OptimizeMethods" value="true" />
<Var name="InPath" value="/Users/sahil.khanna/path_to_xamarin_project/Sample.Android/bin/Release" />
<Var name="OutPath" value="$(InPath)/Obfuscator_Output" />
<Module file="$(InPath)/Sample.dll" />
</Obfuscator>
Strangely, InPath
and OutPath
worked with an absolute path instead of a relative path on a Mac. The only changes I did were in the InPath
and OutPath
to make it work.