Use Obfuscar for publishing applications

1.7k Views Asked by At

I am able to obfuscate a .dll in my visual studio solution upon running it. enter image description here

The problem is that I have no idea how this can be done upon publishing the application into an .exe. Because the source code of the dll inside the published exe can still be seen with a de-obfuscator.

Could someone help me out please? Thanks in advance.

1

There are 1 best solutions below

2
Andreas Damen On BEST ANSWER

I just found the solution. By installing Obfuscar Global Tool and adding the following code to my .csproj file.

<Target Name="Obfuscation" AfterTargets="AfterCompile">
    <Message Text="Obfuscating" Importance="high" />
    <!--Optional to log a message.-->
    <Exec Command="obfuscar.console obfuscar.xml" />
        <!--Assuming you have installed Obfuscar.GlobalTool(attpsifluww.nuget.org/packages/Obfuscar.GlobalTool). -->
    <Exec Command="COPY $(ProjectDir)$(IntermediateOutputPath)Protected\$(TargetFileName) $(ProjectDir)$(IntermediateOutputPath)$(TargetFileName)" />
</Target>

This allowed me to change the dll file on publish.

Thanks everyone for helping me solve this. I really appreciate it!