Unfortunately my approach is not perfect in that it still opens the GUI of Dotfuscator that requires a manual clicking. It is good for me though since I only run it during building in Release mode.
Here is how I run the command during building:
Find the location of Dotfuscator CE which is included in VS2012 by going to Tools -> External Tools.
Copy the path from the Command box.
Open the property of your project and go to Build Events.
Click on Edit Post-build and enter the following
if “$(ConfigurationName)” == “Release” (“%The path copied from the Command box%” /in:”$(TargetPath)” /out:”$(TargetDir)\Dotfuscator”
copy /Y “$(TargetDir)\Dotfuscator\$(TargetFileName)” “$(TargetPath)” )
What these lines do is
1. When the project is being built in Release mode, run the Dotfuscator.
2. Output the altered DLL into a folder named Dotfuscator under your target path (Normally the bin/release folder).
3. Copy this altered DLL to the folder where regular DLL resides and overwrite it.