Skip to Content
New release 12 available 🎉
ObfuscatorMSBuild TaskBabel Task Reference

Babel Task Reference

Every attribute of the Babel MSBuild task, grouped by feature, with the command line option each attribute maps to.

The Babel task exposes one attribute for each option of the command line tool and forwards the attribute values to it unchanged. A Boolean attribute accepts true or false. Where the command line option takes an argument, the same argument can be passed as the attribute value, so an attribute marked Boolean / String accepts either form. List attributes take several values separated by ;. Attributes that are not set keep the defaults listed in the tables.

When the Babel Obfuscator NuGet package is used, each attribute is set through an MSBuild property or item; see the Property Mapping table of the package reference.

Version 12.0 adds the SingleFile, TrustedSigner, TrustedBundle and TrustedTeam attributes, which drive the mobile package-integrity checks of Tampering Detection, and the stream value of StringEncryption. They are marked 12.0 in the tables below.

Miscellaneous

AttributeTypeDefaultCommand lineDescription
BabelDirectoryStringLegacy override of the folder that contains babel.exe. The task fails when the executable is not found there. Prefer ToolPath.
DbgHelpDllDirString--dbghelpdlldirPath of the folder that contains dbghelp.dll.
DetectIfObfuscatedBoolean / Stringfalse--isobfuscatedWhether to detect if the target assembly is already obfuscated. The value warn raises a warning and continues, exit stops without processing the assembly.
EnableObfuscationAgentBooleantrue--agentWhether to run the obfuscation agent, which analyzes the assembly and excludes from obfuscation the symbols that would break it.
LicenseString--licenseFull path of the license file, or a list of directories to search for license files.
NoConfigurationBooleanfalse--noconfigWhether to ignore the default values stored in the Babel configuration file.
NoWarningsString--nowarnList of warning codes to ignore.
ProvideCommandLineArgsBooleanfalseWhether to log the command line passed to Babel and return it in the CommandLineArgs output item.
QuickRulesString--quickruleQuick rule definitions.
RandomSeedString--randomseedSeed of the random number generator used during obfuscation.
RemoveKeyBooleanfalse--removekeyWhether to remove the strong name from the obfuscated assembly.
SatelliteAssembliesString--satelliteList of satellite assembly files to process.
SearchDirectoriesString--addsearchList of directories where the referenced assemblies are searched. References is accepted as an alias.
SearchSatelliteAssembliesBooleantrue--satelliteWhether to search and process the satellite assemblies of the target.
ShowLogoBooleantrue--logoWhether to output the Babel version and copyright information.
ShowStatisticsBooleantrue--statisticsWhether to display the obfuscation statistics at the end of the process. Boolean only: use StatisticsFile to save the statistics to a file.
StatisticsFileString--statisticsPath of the file where the obfuscation statistics are saved. Ignored when ShowStatistics is false.
TargetAssemblyNameStringnochange--assemblynameOrigin of the target assembly name: nochange, inputfilename, outputfilename or name=<assembly name>.
ToolExeStringName of the Babel executable, babel.exe or babel.dll.
ToolPathStringDirectory of the Babel executable.
TraceString--traceList of regular expressions that select the symbols to trace. The trace shows why a symbol is or is not obfuscated and helps debugging the obfuscation rules.
UseKey=Value--useUsage options as key-value pairs.
VerboseLevelInt1--verboseVerbosity of the console output. 0 disables the messages, values above 10 show debug information.
WarningsAsErrorsString--warnaserrorList of warning codes reported as errors. An error stops the obfuscation process.
WarningsAsInfosString--warnasinfoList of warning codes reported as informational messages.
XmlRulesStringInline XML rule elements, see XML Rules.

Input Files

AttributeTypeDefaultCommand lineDescription
InputFileStringPath of the assembly to obfuscate.
KeyContainerString--keynameName of the strong name key container (Windows only).
KeyFileString--keyfilePath of the strong name key file used to sign the obfuscated assembly.
KeyPwdString--keypwdPassword of the strong name key file or certificate.
MapInFilesString--mapinList of XML map files of already obfuscated assemblies, used to rename the references to their symbols.
ProjectString--projectPath of a Babel obfuscation project file.
RulesFilesString--rulesList of XML rules files to process.

Output Files

AttributeTypeDefaultCommand lineDescription
GenerateLogFileBooleanfalse--logfileWhether to generate an obfuscation log. The default log file name is <target assembly>.log.
GenerateMapOutFileBooleanfalse--mapoutWhether to generate an obfuscation map file. The default map file name is <target assembly>.xml.map.
LogFileString--logfilePath of the obfuscation log file.
MakeProjectString--makeprojectPath of the MSBuild project file created from the task settings.
MapOutFileString--mapoutPath of the obfuscation map file.
OutputFileString--outputPath of the obfuscated assembly.
PdbFileString--pdbPath of the debug symbols file.
PdbPwdString--pdbpwdPassword of the debug symbols file.

Plugins

AttributeTypeDefaultCommand lineDescription
PluginsString--pluginList of plugin assembly files.
PluginsArgumentsKey=Value--argumentPlugin arguments as key-value pairs.

Merge and Embed

AttributeTypeDefaultCommand lineDescription
CopyAttributesBoolean / Stringfalse--copyattrsWhether the assembly level attributes of the merged assemblies are copied into the target assembly. A regular expression selects the duplicate attributes that can be merged.
DependenciesManifestBooleantrue--jsonmanifestWhether to update the .deps.json dependencies manifest of the target assembly when assemblies are merged or embedded.
EmbedAssembliesString--embedList of assembly files to embed into the target assembly.
InternalizeBooleanfalse--internalizeWhether the merged types have their visibility restricted to the target assembly.
MergeAssembliesStringList of assembly files to merge into the target assembly.

Renaming

AttributeTypeDefaultCommand lineDescription
FlattenNamespacesBoolean / Stringtrue--flatnsWhether to move the renamed types into the global namespace. A string sets a common namespace name for the renamed types instead.
NameLengthInt / Key=Value--namelengthMinimum length of the obfuscated names. Key-value pairs assign the length to a given symbol kind.
NamePrefixString / Key=Value--nameprefixPrefix of the obfuscated names, $name or any string. Key-value pairs assign the prefix to a given symbol kind.
ObfuscateEventsBooleantrue--eventsWhether to rename events.
ObfuscateFieldsBooleantrue--fieldsWhether to rename fields.
ObfuscateMethodsBooleantrue--methodsWhether to rename methods.
ObfuscateParametersBooleantrue--parametersWhether to rename method parameters.
ObfuscatePropertiesBooleantrue--propertiesWhether to rename properties.
ObfuscateTypesBooleantrue--typesWhether to rename types.
ObfuscateXamlBoolean / Key=Valuefalse--xamlWhether to rename the symbols referenced by XAML and BAML resources. Key-value pairs configure the renaming.
OverloadedRenamingBoolean / Key=Valuefalse--overloadedWhether to reuse the same name for members with different signatures. Key-value pairs select which members are overloaded.
UnicodeNormalizationBoolean / Stringfalse--unicodeWhether to generate names using Unicode characters. When disabled, ASCII characters are used. A comma-separated list of characters or ranges restricts the character set.
VirtualFunctionsBoolean / Key=Valuetrue--virtualWhether to rename virtual members. Key-value pairs configure the renaming of external overrides.
XmlDocFilesString--xmldocList of XML documentation files to process together with the assembly. XmlDoc is accepted as a legacy alias.

Control Flow Obfuscation

AttributeTypeDefaultCommand lineDescription
ControlFlowObfuscationBoolean / Key=Valuefalse--controlflowWhether to obfuscate the control flow of the methods. Key-value pairs select the algorithms, including chain=on for Chained State Ultimate.
ControlFlowIterationsInt3--iterationsNumber of iterations of the control flow obfuscation algorithms. 0 disables control flow obfuscation. ILIterations and Iterations are accepted as aliases.
EmitInvalidOpcodesBoolean / Stringfalse--invalidopcodesWhether to emit invalid MSIL op-codes, which makes the assembly not verifiable. The value enhanced inserts additional invalid op-codes.

Encryption and Protection

AttributeTypeDefaultCommand lineDescription
DebuggingProtectionBooleanfalse--antidebuggingWhether to enable anti-debugging protection.
DynamicProxyBoolean / Stringfalse--proxyWhether to wrap method calls in dynamically generated proxies. The value selects the calls to proxy: internal, external or all.
DynamicProxyCallFiltersString--proxyList of regular expressions that select the method calls to proxy.
MsilEncryptionBoolean / Stringfalse--msilencryptionWhether to encrypt the MSIL code of the methods. Regular expressions select the methods to encrypt by signature.
ResourceEncryptionBoolean / Key=Valuefalse--resourceencryptionWhether to encrypt the managed resources. Key-value pairs enable encryption and compression separately.
SingleFile 12.0Booleanfalse--singlefileSignals that the target is published as a single-file, trimmed or NativeAOT application. On desktop targets the tampering detection check is inert for such a publish, and Babel emits a warning when it is requested.
StringEncryptionBoolean / Stringfalse--stringencryptionWhether to encrypt the user strings. The value selects the algorithm: xor, hash, or stream 12.0 Ultimate.
SuppressIldasmBooleanfalse--ildasmWhether to prevent ILDASM from disassembling the obfuscated assembly.
SuppressReflectionBoolean / Intfalse--reflectionWhether to emit invalid metadata that stops reflection-based tools. An integer sets the level: the higher the level, the more invalid metadata is generated.
TamperingDetectionBooleanfalse--tamperingdetectionWhether to enable tampering detection.
TrustedBundle 12.0 UltimateString--trustedbundleTrusted iOS bundle identifier (CFBundleIdentifier) pinned by the iOS package-integrity check.
TrustedSigner 12.0 UltimateString--trustedsignerList of SHA-256 fingerprints, 64 hexadecimal characters each, of the trusted Android APK signing certificates pinned by the Android package-integrity check.
TrustedTeam 12.0 UltimateString--trustedteamTrusted Apple Developer Team ID pinned by the iOS package-integrity check.
ValueEncryptionBoolean / Key=Valuefalse--valueencryptionWhether to encrypt the constant values and arrays. Key-value pairs select the kinds of value to encrypt.

Optimizations

AttributeTypeDefaultCommand lineDescription
CleanAttributesBoolean / Stringfalse--cleanattrsWhether to remove unwanted attributes. Regular expressions select the full names of the attribute types to remove.
ConstRemovalBooleanfalse--constremovalWhether to remove the constant fields.
DeadCodeEliminationBoolean / Stringfalse--deadcodeWhether to remove the methods, properties and events not used by the application. Regular expressions set the entry points where the search starts.
DisgregateRemovalBooleanfalse--disgregateremovalWhether to remove the property and event metadata.
EnumRemovalBooleanfalse--enumremovalWhether to remove the System.Enum types.
InlineExpansionBooleanfalse--inlineexpansionWhether to replace the calls to the methods marked for inline expansion with the method body.
SealClassesBooleanfalse--sealWhether to seal the classes that are not used in any inheritance chain.

Code Generation

AttributeTypeDefaultCommand lineDescription
AddReferencesString--addreferenceList of assemblies to add as references of the target assembly.
FrameworkStringTarget framework name forced for the processed assembly.
GenerateDebugBoolean / Stringfalse--debugWhether to generate the debug symbols of the obfuscated assembly. A symbol store path can be specified as the value.
InstrumentBoolean / Stringfalse--instrumentWhether to instrument the code. Regular expressions select the full names of the methods to instrument.
InstrumentEmptyMethodsBooleanfalse--emptymethodsWhether to instrument the methods with an empty body.
ModuleInitializerBoolean / Stringfalse--moduleinitializerWhether to add module initializer code to the target assembly.
ModuleInitializerTargetString--moduleinitializerSignature of the static method, without parameters, called after the module loads.
ModuleVersionIdBoolean / Stringfalse--moduleversionidWhether to set the module version identifier (MVID) of the obfuscated assembly. A GUID string sets the value, otherwise a random one is generated.

Packages

AttributeTypeDefaultCommand lineDescription
AndroidSigningKeyAliasString--keyaliasAlias of the key in the Android key store (APK packages).
AndroidSigningKeyPassString--keypassPassword of the key in the Android key store (APK packages).
AndroidSigningKeyStoreString--keystoreAndroid key store file (APK packages).
AndroidSigningStorePassString--storepassPassword of the Android key store (APK packages).
RemoveFilesString--removeList of deployed assemblies to remove from the package.
SkipFilesString--skipList of deployed assemblies that are not obfuscated.
TakeFilesString--takeList of deployed assemblies to obfuscate.
XapCompressionLevelInt6--compressCompression level of the package, from 0 (no compression) to 9 (XAP packages).

Task Outputs

OutputDescription
CommandLineArgsThe command line passed to Babel, available when ProvideCommandLineArgs is true.
ExitCodeThe exit code returned by Babel.

Example

The task below obfuscates the intermediate assembly of a .NET MAUI Android project with STREAM string encryption and tampering detection pinned to the APK signing certificate, and captures the command line passed to Babel:

<Target Name="Obfuscate" AfterTargets="Compile" Condition="'$(DesignTimeBuild)' != 'true'"> <Babel InputFile="$(ProjectDir)$(IntermediateOutputPath)$(TargetFileName)" OutputFile="$(ProjectDir)$(IntermediateOutputPath)$(TargetFileName)" StringEncryption="stream" ControlFlowObfuscation="true" ControlFlowIterations="3" TamperingDetection="true" TrustedSigner="2924C53EE9C511E9F26E0720FD8151064F7621681667D7AB1899E551CDB25104" ProvideCommandLineArgs="true"> <Output TaskParameter="CommandLineArgs" ItemName="BabelCommandLineArgs" /> </Babel> <Message Importance="high" Text="@(BabelCommandLineArgs, ' ')" /> </Target>
Last updated on