'.NET 6 obfuscation

I'm trying to obfuscate an .exe file obtained after compiling my .NET 6 project with the "Produce a single file" option, the problem is that no obfuscator works on it, I wanted to know if anyone knows why?

Thanks in advance for your answer



Solution 1:[1]

You have to obfuscate main application dll, which is located in the "obj\Release\net6.0-windows\win-x64" folder and copy obfuscated dll to the path.

Here is a working example using Obfuscar. These lines are located in the .csproj file.

    <Target Name="Obfuscation" AfterTargets="AfterCompile" Condition="'$(PublishProtocol)'!=''">
        <Exec Command="&quot;$(Obfuscar)&quot; obfuscar.xml" />
    </Target>
    <Target Name="PostBuild" AfterTargets="PostBuildEvent" Condition="'$(PublishProtocol)'!=''">
        <Exec Command="COPY &quot;C:\Users\Application\obj\Release\net6.0-windows\win-x64\Obfuscated\Application.dll&quot; &quot;C:\Users\Application\obj\Release\net6.0-windows\win-x64\Application.dll&quot;" />
    </Target>

After that, when you publish single file exe, your application code inside the archive will be obfuscated.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Ozan Budak