How can we help you today? How can we help you today?

how do you obfuscate all items in a publish to single file app

how do you obfuscate all items in a publish to single file app
rick105
0

Comments

1 comment

  • Jon Kirkwood
    Official comment

    Hi rick105

     

    Thank you for reaching out on the Redgate forums regarding your SmartAssembly question regarding obfuscating into a single file app.

    When publishing a .NET application as a single file, SmartAssembly can still obfuscate it, but some extra steps are required since the assembly is embedded within the single file executable. 

    Here’s a possible method on how this can be achieved 

    1. Publish Without Single File First

    SmartAssembly needs access to the raw assembly (.dll) before it gets bundled into a single file.

    • Publish your app without the PublishSingleFile option first:
      dotnet publish -c Release -r win-x64 --self-contained false
    • This generates a normal set of .dll files in the bin\Release\netX\publish\ folder.

    2. Obfuscate with SmartAssembly

    • Open SmartAssembly and create a new project.
    • Add your main application .dll (e.g., MyApp.dll).
    • Configure obfuscation, string encryption, control flow obfuscation, etc.
    • Build the obfuscated .dll.

    3. Publish as Single File Manually

    Now, repackage the obfuscated assembly into a single file:

    • Replace the original .dll with the obfuscated version.
    • Run the dotnet publish command with single file enabled:
      dotnet publish -c Release -r win-x64 -p:PublishSingleFile=true -p:IncludeAllContentForSelfExtract=true --self-contained false 
      The IncludeAllContentForSelfExtract=true ensures embedded assemblies can still be loaded properly.

    4. Test the Application

    • Run the generated .exe and verify functionality.
    • Use a decompiler to confirm that obfuscation is applied.

    Hopefully this process can be used to obfuscate your project and end with a single file executable as desired.

    Jon Kirkwood

Add comment

Please sign in to leave a comment.