ClickOnce Deploy

In ClickOnce deployment, the Babel task is configured to obfuscate the target assembly just after the Compile step.

Open the Visual Studio .csproj file and append the following MSBuild instructions before the Project close element.

<UsingTask TaskName="Babel" AssemblyName="Babel.Build, Version=10.0.0.0, Culture=neutral, PublicKeyToken=138d17b5bd621ab7" />
  
<Target Name="Obfuscate" AfterTargets="Compile" Condition="'$(Configuration)|$(Platform)' == 'Release|AnyCPU'">
  
<Babel InputFile="$(ProjectDir)$(IntermediateOutputPath)$(TargetFileName)" OutputFile="$(ProjectDir)$(IntermediateOutputPath)$(TargetFileName)" ObfuscateTypes="true" ObfuscateEvents="true" ObfuscateMethods="true" ObfuscateProperties="true" ObfuscateFields="true" VirtualFunctions="true" UnicodeNormalization="true" FlattenNamespaces="true" OverloadedRenaming="true" StringEncryption="hash" ControlFLowObfuscation="if=on;switch=on;case=on;call=on" ControlFLowIterations="3" />

</Target>

Note that the InputFile and OutputFile task attributes are set to intermediate build output. This will allow Visual Studio to create the ClickOnce deployable package using the obfuscated target assembly.

Babel Obfuscator NuGet Package

If you have the Babel.Obfuscator NuGet package, there is no need to set up the Babel task in your project file. Just adds the NuGet package reference to your project.

Download the example source code.

Last updated