The question is, how do you configure Visual Studio to do this, to selectively build non-obfuscated assemblies in one run and then build obfuscated assemblies in another run? The answer is to create a new solution configuration which I name ObfuscatedRelease. To do this means my Visual Studio solution must be configured so that I am able to selectively build non-obfuscated assemblies or obfuscated assemblies. In other words, is the problem related to the process of obfuscation? So under the release configuration, my tests (e.g., unit, integration, specification) can be run against the non-obfuscated assemblies and the obfuscated assemblies. The reason for this is if a problem occurs when using the obfuscated assemblies then I want to be able to test if the same problem occurs in the non-obfuscated assemblies. On the other hand, under the Release solution configuration, I want to be able to build both non-obfuscated assemblies and obfuscated assemblies. So when the Debug solution configuration is selected, then my tests (e.g., unit, integration, specification) are only run against the non-obfuscated assemblies. I have not come across any reason for obfuscating assemblies built under the Debug solution configuration. The question is, which of these configurations do you apply obfuscation to? When and When Not to Obfuscate?īy default, projects in a Visual Studio solution are configured with two solution configurations – the Debug solution configuration and the Release solution configuration. Other articles worth reading are this and this. Those of you who are new to obfuscation should read the article " Giving a NET Assembly a Strong Name" as it describes the difference between obfuscating a strong named assembly and obfuscating a delay signed assembly. In short, strong named assemblies are signed with the private token key from a cryptographic strong name key file, delay signed assemblies are signed with the public token key from a cryptographic strong name key file and private assemblies are not signed. This article assumes you understand the difference between these three types of assemblies.
Dotfuscator visual studio 2019 how to#
The sample solution included with this article illustrates how to obfuscate private assemblies, strong named assemblies and delay signed assemblies. The sample solution uses PowerShell scripts. When the requirements are very simple, then the script can be written using batch commands and batch files, otherwise my recommendation is to write PowerShell scripts. In the current context, the script executes commands that obfuscate a project’s assembly. A post-build event is a user supplied script that executes a sequence of commands. More specifically, an assembly is obfuscated when a project’s post-build event is executed. In the sample solution, an assembly is obfuscated immediately after a project’s assembly has been built. When Does a Project’s Assembly Get Obfuscated? However, most of the information in this article is applicable to other obfuscators that include a command line program. I found the GUI program is useful as a learning tool whereas the command line program is useful in automating the build process.ĭevelopment on and support of the ConfuserEx obfuscator stopped as of July, 2016. The sample solution included with this article does not use Dotfuscator but instead uses the obfuscator ConfuserEx, an open source project.Īssemblies can be obfuscated using a GUI program or a command line program - each has its use. The obfuscator included with Visual Studio is the community edition of Dotfuscator. How Does an Assembly Get Obfuscated?Īn assembly is obfuscated using a program called an obfuscator. It is this assembly PrivateAssembly.dll which gets obfuscated. When this project is built, then the output is an assembly named PrivateAssembly.dll. For example, one of the projects in the sample solution included with this article is named PrivateAssembly. The answer is the assembly created when a project is built.
Dotfuscator visual studio 2019 code#
One of the questions I found posted in several forums asked what gets obfuscated, the source code or the assembly created when a project is built. It does not discuss the theory behind obfuscation or the effectiveness of obfuscation in protecting your intellectual property. It explains how to configure Visual Studio for obfuscation. This is an introductory article about obfuscation in Visual Studio.