In this post, I will show you how to use PreEmptive Dotfuscator Community Edition in Visual Studio 2010 setup project to protect code.
By default, PreEmptive Dotfuscator CE is integrated in Visual Studio 2010, however, it does not support the command line execution and you will need the command line ability to make it work in VS setup project. The command line file is called dotfuscatorCLI.exe and can be downloaded from PreEmptive’s web site after you register: http://www.preemptive.com/support/dotfuscator-support. After registration, download the CE installer and executed, it should automatically add the command line exe file to your computer.
Now let’s see how to use it in the setup project.
I assume you know how to add Project Output of your target application to the setup project, so I will skip this step. Now, right-click your target application in the Solution Explorer and choose Properties, then click on Build Events option on the left side:
Click on Edit Post-build button and type in the following commands:
"C:\Program Files (x86)\Microsoft Visual Studio 10.0\PreEmptive Solutions\Dotfuscator Community Edition\dotfuscatorCLI.exe" /in:$(TargetFileName)
copy /y "$(TargetDir)Dotfuscated\$(TargetFileName)" "$(TargetDir)$(TargetFileName)"
The first command is to run Dotfuscator in the command line on the target application to generate a dotfuscated version of the project output. Since by default, Dotfuscator will store the dotfuscated output under a subfolder called “Dotfuscated”, the second command is basically copy the dotfuscated project output and overwrite the un-dotfuscated project output, therefore, when you build your setup project, the dotfuscated project output will be packaged in the final installer package.
Hope this will help someone.