How to install and use obfuscar?
I set this up to run on the Post Build event in Visual Studio.
- Add Obfuscar NuGet Package to your solution.
Add obfuscar.xml file to your project and change Copy to Output Directory: Always. See the post on this thread by vinsa for an XML sample. I had to include the full path to my project in "InPath" variable. Then the obfucasted folder was under bin/[debug / release].
In the Visual Studio post build events enter: "$(Obfuscar)" obfuscar.xml
- Download the Obfuscar.Console.exe you can download from Nuget, then unzip obfuscar.versionnumber.nupkg, and find the exe.
- Besides exe, create one input folder and one output folder. put BasicExemple.exe into input folder.
Besides exe, create plain text file(config.xml for example), and the contents can be very simple:
<?xml version='1.0'?> <Obfuscator> <Var name="InPath" value=".\input folder name" /> <Var name="OutPath" value=".\output folder name" /> <Module file="$(InPath)\BasicExemple.exe" /> </Obfuscator>
Run cmd, cd to exe's directory, then run
Obfuscar.Console.exe config.xml
The output folder will contain the processed binary.
I have just created an extended configuration file for Obfuscar and would like to share it.
Full list of available parameters here.
<?xml version='1.0'?>
<Obfuscator>
<Var name="InPath" value="." />
<Var name="OutPath" value=".\Obfuscator_Output" />
<Var name="KeepPublicApi" value="false" />
<Var name="HidePrivateApi" value="true" />
<Var name="RenameProperties" value="true" />
<Var name="RenameEvents" value="true" />
<Var name="RenameFields" value="true" />
<Var name="UseUnicodeNames" value="true" />
<Var name="HideStrings" value="true" />
<Var name="OptimizeMethods" value="true" />
<Var name="SuppressIldasm" value="true" />
<Module file="$(InPath)\MyApplication.exe" />
</Obfuscator>