Recently I was looking at couple of products to obfuscate C# code and came across Obfuscar.
You can run Obfuscar via a command line or on the Post Build Events in Visual Studio.
There are a few steps to add this to the post build of any project.
1. Add Obfuscar NuGet Package to your solution.
2. Add obfuscar.xml file to your project and change Copy to Output Directory: Always.
In this config I want to obfuscate a DLL for a blockchain project I am working on.
<?xml version='1.0'?>
<Obfuscator>
<Var name="InPath" value="C:...[path to your project output folder]" />
<Var name="OutPath" value="$(InPath)\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)\CoinControl.dll" />
</Obfuscator>
3. In the Visual Studio post build events enter: "$(Obfuscar)" obfuscar.xml
After you run the build (in your debug or release folder) you will have a fully obfuscated binary under a folder named: Obfuscator_Output.