Skip to Content
New release 12 available 🎉
ObfuscatorNuGet PackagePackage Reference

Package Reference

Every MSBuild property, item and target defined by the Babel.Obfuscator package, and the mapping between the package properties and the attributes of the Babel task.

Package Properties

The properties below control the package itself. Obfuscation settings are listed in the Property Mapping table.

PropertyDefaultDescription
BabelEnabledtrueMaster switch. When false, no Babel target runs, publish adjustments included.
BabelPublishEnabled$(BabelEnabled)Whether merged and embedded assemblies are removed from the publish set.
BabelUpdateDependencyFile$(BabelEnabled)Whether the build and publish .deps.json files are updated after obfuscation.
BabelOverrideCompiletrueWhether the package injects the obfuscation step after CoreCompile. Set to false to wire the ObfuscateBuild target yourself.
RunBabelAfterBuildfalseWhen true, Babel runs at the end of the build on $(TargetPath) instead of on the intermediate assembly.
BabelBeforeTargetsRuns the obfuscation step before the named target, disabling the default placement.
BabelAfterTargetsRuns the obfuscation step after the named target, disabling the default placement.
BabelPackageDirpackage rootRoot folder of the extracted package.
BabelTaskDirper hostFolder the Babel task and tools are loaded from; see Selecting the Build Tools.
BabelPath$(BabelTaskDir)Folder of the Babel executable to run (task attribute ToolPath).
BabelExeName of the Babel executable, babel.exe or babel.dll (task attribute ToolExe).
BabelInputFileintermediate assemblyAssembly to obfuscate. Computed by the package; override it in a settings target.
BabelOutputFile$(BabelInputFile)Obfuscated output. Computed by the package; override it in a settings target.
BabelLicensebabel.licenses found in the project folder or a parent folderLicense file path, license key or floating: user key.
BabelLicenseDirFolder where babel.licenses was found, set by the package.
SymbolsRenamingtrueEnables or disables every renaming feature at once.
NoConfigurationtrueWhether Babel ignores its configuration file.
GenerateDebugtrue when a PDB existsWhether debug symbols are generated for the obfuscated assembly.
CopyOutputSymbolsToPublishDirectoryfalse in ReleaseStandard SDK property; the package turns it off in Release so PDB files are not published.
BabelProvideCommandLineArgsfalseWrites the Babel command line to the log and to the @(BabelCommandLineArgs) item.
BabelWarningsAsErrorsWarning codes to report as errors. Set it to W00000 to fail builds that run in evaluation mode.
BabelWarningsAsInfosWarning codes to report as informational messages.
BabelWarningsToIgnoreWarning codes to suppress.
BabelExitCodeOutput: exit code of the Babel task, available after CoreObfuscate.

Package Items

ItemDescription
BabelRulesXML rules files. babelRules.xml in the project folder is added automatically.
MergeAssemblyAssemblies to merge into the target assembly.
EmbedAssemblyAssemblies to embed in the target assembly.
MapInFileXML map files of already obfuscated assemblies.
BabelPluginPlugin assemblies to load.
BabelSearchDirectoriesAssembly search directories. Computed from the project references; replace or extend it in a settings target.
BabelTargetReferencesAdditional search entries passed as references.
AddReferencesAssemblies to add as references of the obfuscated assembly.
SatelliteAssemblySatellite assemblies to process.
XmlDocumentationFileXML documentation files to process together with the assembly.
BabelCommandLineArgsOutput: the command line passed to Babel, when BabelProvideCommandLineArgs is true.

Targets

TargetDescription
ObfuscateBuildThe obfuscation step injected into the build. Runs ObfuscateSettings then Obfuscate.
ObfuscateSettingsPrepares the Babel task configuration by running the settings targets below.
ObfuscateDefaultSettingsApplies the renaming defaults, looks up the license file, adds babelRules.xml and builds the search directories.
ObfuscateFrameworkSettingsSelects the assembly to process: the intermediate assembly, or $(TargetPath) when RunBabelAfterBuild is true.
ObfuscateSetupBabelFilesSets BabelInputFile and BabelOutputFile, and enables GenerateDebug when a PDB exists.
ObfuscateCustomSettings, SetupObfuscate, ConfigureBabelEmpty targets, redefine them to adjust the computed configuration before Babel runs.
ObfuscateRuns BeforeObfuscate, CoreObfuscate and AfterObfuscate.
BeforeObfuscateEmpty target, redefine it to run tasks just before the Babel task.
CoreObfuscateRuns the Babel task. Do not redefine it.
AfterObfuscateEmpty target, redefine it to run tasks just after the Babel task.
UpdateBabelBuildDependencyFileAfter GenerateBuildDependencyFile: removes merged and embedded assemblies and the package from the build .deps.json.
UpdateBabelPublishDependencyFileAfter GeneratePublishDependencyFile: the same for the publish .deps.json.
UpdateBabelFilesToPublishAfter ComputeFilesToPublish: removes merged and embedded assemblies from the publish set.
OverrideCompileWithBabelAfter PrepareForBuild: inserts ObfuscateBuild after CoreCompile, unless the step has been moved or the build is a design-time build.
EnableObfuscationFlagTriggered by compilation: enables ObfuscateBuild only when the compiler actually ran.

Property Mapping

The table maps every attribute of the Babel task to the MSBuild property or item the package reads. Properties accept the same values as the corresponding command line switch. Attributes marked 12.0 were added in version 12.

Babel task attributeKindPackage property or item
AddReferencesItem@(AddReferences)
AndroidSigningKeyAliasPropertyAndroidSigningKeyAlias
AndroidSigningKeyPassPropertyAndroidSigningKeyPass
AndroidSigningKeyStorePropertyAndroidSigningKeyStore
AndroidSigningStorePassPropertyAndroidSigningStorePass
BabelDirectoryPropertyBabelDirectory
CleanAttributesPropertyCleanAttributes
ConstRemovalPropertyConstRemoval
ControlFlowIterationsPropertyControlFlowIterations (ILIterations is accepted as an alias)
ControlFlowObfuscationPropertyControlFlowObfuscation
CopyAttributesPropertyMergeCopyAttributes
DbgHelpDllDirPropertyDbgHelpDllDir
DeadCodeEliminationPropertyDeadCodeElimination
DebuggingProtectionPropertyDebuggingProtection
DependenciesManifestPropertyDependenciesManifest
DetectIfObfuscatedPropertyDetectIfObfuscated
DisgregateRemovalPropertyDisgregateRemoval
DynamicProxyPropertyDynamicProxy
DynamicProxyCallFiltersPropertyDynamicProxyCallFilters
EmbedAssembliesItem@(EmbedAssembly)
EmitInvalidOpcodesPropertyEmitInvalidOpcodes
EnableObfuscationAgentPropertyEnableObfuscationAgent
EnumRemovalPropertyEnumRemoval
FlattenNamespacesPropertyFlattenNamespaces
FrameworkPropertyFramework
GenerateDebugPropertyGenerateDebug
GenerateLogFilePropertyGenerateLogFile
GenerateMapOutFilePropertyGenerateMapOutFile
InlineExpansionPropertyInlineExpansion
InputFilePropertyBabelInputFile
InstrumentPropertyBabelInstrument
InstrumentEmptyMethodsPropertyInstrumentEmptyMethods
InternalizePropertyMergeInternalize
KeyContainerPropertyKeyContainerName
KeyFilePropertyKeyOriginatorFile
KeyPwdPropertySigningCertPassword
LicensePropertyBabelLicense
LogFilePropertyBabelLogFile
MakeProjectPropertyMakeBabelProjectFile
MapInFilesItem@(MapInFile)
MapOutFilePropertyBabelMapOutFile
MergeAssembliesItem@(MergeAssembly)
ModuleInitializerPropertyModuleInitializer
ModuleInitializerTargetPropertyModuleInitializerTarget
ModuleVersionIdPropertyModuleVersionId
MsilEncryptionPropertyMsilEncryption
NameLengthPropertyNameLength
NamePrefixPropertyNamePrefix
NoConfigurationPropertyNoConfiguration
NoWarningsPropertyBabelWarningsToIgnore
ObfuscateEventsPropertyObfuscateEvents
ObfuscateFieldsPropertyObfuscateFields
ObfuscateMethodsPropertyObfuscateMethods
ObfuscateParametersPropertyObfuscateParameters
ObfuscatePropertiesPropertyObfuscateProperties
ObfuscateTypesPropertyObfuscateTypes
ObfuscateXamlPropertyObfuscateXaml
OutputFilePropertyBabelOutputFile
OverloadedRenamingPropertyOverloadedRenaming
PdbFilePropertyPdbFile
PdbPwdPropertyPdbPwd
PluginsItem@(BabelPlugin)
PluginsArgumentsPropertyPluginsArguments
ProvideCommandLineArgsPropertyBabelProvideCommandLineArgs
RandomSeedPropertyRandomSeed
ReferencesItem@(BabelTargetReferences)
RemoveFilesPropertyBabelRemoveFiles
ResourceEncryptionPropertyResourceEncryption
RulesFilesItem@(BabelRules)
SatelliteAssembliesItem@(SatelliteAssembly)
SealClassesPropertySealClasses
SearchDirectoriesItem@(BabelSearchDirectories)
SearchSatelliteAssembliesPropertySearchSatelliteAssemblies
ShowLogoPropertyShowLogo
ShowStatisticsPropertyShowStatistics
SingleFilePropertyPublishSingleFile (standard SDK property)
SkipFilesPropertyBabelSkipFiles
StatisticsFilePropertyStatisticsFile
StringEncryptionPropertyStringEncryption
SuppressIldasmPropertySuppressIldasm
SuppressReflectionPropertySuppressReflection
TakeFilesPropertyBabelTakeFiles
TamperingDetectionPropertyTamperingDetection
TargetAssemblyNamePropertyTargetAssemblyName
ToolExePropertyBabelExe
ToolPathPropertyBabelPath
TracePropertyTrace
TrustedBundle 12.0PropertyTrustedBundle
TrustedSigner 12.0PropertyTrustedSigner (several fingerprints separated by ;)
TrustedTeam 12.0PropertyTrustedTeam
UnicodeNormalizationPropertyUnicodeNormalization
UsePropertyUse
ValueEncryptionPropertyValueEncryption
VerboseLevelPropertyVerboseLevel
VirtualFunctionsPropertyVirtualFunctions
WarningsAsErrorsPropertyBabelWarningsAsErrors
WarningsAsInfosPropertyBabelWarningsAsInfos
XapCompressionLevelPropertyXapCompressionLevel
XmlDocFilesItem@(XmlDocumentationFile)
XmlRulesPropertyXmlRules

Setting the String Encryption Algorithm

The StringEncryption package property enables string encryption and selects the algorithm, exactly like the --stringencryption command-line switch. Accepted values are xor, hash, stream and custom (see String Encryption for a description of each). A boolean true enables string encryption with the default algorithm, while an algorithm name both enables it and selects that algorithm.

For example, to encrypt strings with the STREAM algorithm (authenticated per-string encryption, fully managed, AOT/trim/FIPS-safe, and supported from .NET Framework through .NET 10 including Android/iOS/MAUI), add to your project file:

<PropertyGroup> <StringEncryption>stream</StringEncryption> </PropertyGroup>

The STREAM algorithm Ultimate is not included in lower editions: with those, stream falls back to the default algorithm.

On .NET Android / iOS / MAUI projects, run the obfuscation as a string-encryption-only pass so that type and member names stay intact for the platform interop layer.

Last updated on