This article describes the MSBuild targets, properties, and item metadata supported by Dotfuscator.
For an introduction to integrating Dotfuscator with MSBuild, see Protect Your App with MSBuild.
Install Location
The location of the Dotfuscator MSBuild components depends on how Dotfuscator was installed.
| Installation Package | Directory |
|---|---|
| Windows Installer | $(MSBuildProgramFiles32)\MSBuild\PreEmptive\Dotfuscator\7 |
| NuGet Package | {install dir}/tools/msbuilddir |
where:
| Variable | Description |
|---|---|
$(MSBuildProgramFiles32) |
Reserved MSBuild property that points to C:\Program Files (x86) on 64-bit Windows or C:\Program Files on 32-bit Windows. |
{install dir} |
Directory where the Dotfuscator NuGet package was installed. |
MSBuild Targets
Dotfuscator provides the PreEmptive.Dotfuscator.Common.targets MSBuild targets file to integrate protection into an MSBuild project.
The targets run Dotfuscator after the project is built and before the application is packaged.
MSBuild Targets Properties
The following properties are recognized by the Dotfuscator MSBuild targets.
| Property | Description | Default |
DotfuscatorEnabled |
Enables or disables Dotfuscator during the build. When true, Dotfuscator protects the project. When false, Dotfuscator is skipped. Available in the project that imports the Dotfuscator MSBuild targets. |
false |
DotfuscatorConfigPath |
Specifies the path to the Dotfuscator configuration file relative to the project file. If DotfuscatorGenerateConfigFileIfMissing is true, the file does not need to exist before the build. |
DotfuscatorConfig.xml |
DotfuscatorGenerateConfigFileIfMissing |
Determines how Dotfuscator behaves when the configuration file is missing. When true, Dotfuscator generates a new configuration file. When false, the build fails. |
true |
DotfuscatorAndroidSigningCertFingerprint |
Specifies the SHA-1 fingerprint of the certificate used to sign a Xamarin.Android application. Required only when injecting Tamper Check into a Xamarin.Android application. If key rotation is enabled and the application targets Android Pie (API 28) or later, specify the last alias in the rotation; otherwise, specify the first alias. | Not set |
DotfuscatorLicense |
Specifies the Dotfuscator license string to use during the build, typically for a Floating License. This value overrides licenses supplied through environment variables or license files. | Not set |
DotfuscatorIncludeAsInput |
Determines whether the current project's assembly is included as an input when another project integrates Dotfuscator and references this project. Available only in referenced project files. | true |
Item Metadata
The following metadata are recognized by the Dotfuscator MSBuild targets.
| Metadata | Description | Applies To | Default |
DotfuscatorIncludeAsInput |
Determines whether a referenced assembly is included as an input to Dotfuscator. Supported only on Reference items. Setting this metadata on ProjectReference or PackageReference items is not supported and causes the build to fail. |
Reference items |
false |
MSBuild Tasks
Dotfuscator provides an MSBuild interface through two task libraries.
- Legacy Library:
legacy/PreEmptive.Dotfuscator.Tasks.dll - Modern Library:
PreEmptive.Dotfuscator.Tasks.dll
The two libraries contain the same task definitions but target different sets of MSBuild flavors and versions. The table below summarizes what MSBuild installations support each version.
| MSBuild Flavor | MSBuild Version | Legacy Library | Modern Library |
|---|---|---|---|
| .NET Framework | 4 - 14 | ✅ | ❌ |
| .NET Framework | 15 + | ✅ | ✅ |
| .NET Core | 16 + | ❌ | ✅ |
| Mono | 16 + | ❌ | ✅ |
Dotfuscate Task
You can run Dotfuscator from MSBuild using the Dotfuscate task. Below are the properties provided by the Dotfuscate task.
| Property | Type | Direction | Description |
|---|---|---|---|
ConfigPath
|
string
|
Input | Required. Sets the path to the Dotfuscator config. |
DebugSymbols
|
string[]
|
Output | Exposes PDB files associated with output assemblies. The PreEmptive.Dotfuscator.targets file exposes this property as an output Item named DotfuscatedDebugSymbols |
InputAssemblies
|
ITaskItem[]
|
Input | Sets the input assemblies. Inputs specified in InputAssemblies are merged with the inputs listed in the Dotfuscator config. |
InputManagement
|
string
|
Input |
Sets how the Dotfuscate task uses inputs. If automatic Dotfuscator
gets inputs only from the InputAssemblies property
and updates the inputs in the config to match. If manual or
unspecified, Dotfuscator merges the inputs specified in InputAssemblies and
specified in the config.
|
License
|
string
|
Input | Specifies a Dotfuscator license string to activate and use for this run of Dotfuscator. Typically this property is used for a Floating License. The value of this property is used even if another license is specified by an environment variable or in the license file. |
MappingFile
|
string
|
Output | Exposes the renaming map file. The PreEmptive.Dotfuscator.targets file exposes this property as an output Item named DotfuscatorMappingFile. |
OutputAssemblies
|
string[]
|
Output | Exposes output assemblies. The PreEmptive.Dotfuscator.targets file exposes this property as an output Item named DotfuscatedAssemblies. |
OutputDirectory
|
string
|
Input | Sets the directory where Dotfuscator writes the output assemblies. This overrides the output directory specified in the Dotfuscator config. |
Properties
|
string
|
Input |
Sets user-defined external properties. The string should consist
of XML elements, with the name and element value mapped to the
property
name and value respectively. For example: <Property1>Value1</Property1><Property2>2</Property2>The use of XML elements allows the properties to be defined intuitively in MSBuild project files as MSBuild properties like so: <PropertyGroup><MyDotfuscatorProperties><Property1>Value1</Property1><Property2>2</Property2></MyDotfuscatorProperties></PropertyGroup>You can then pass $(MyDotfuscatorProperties) to
this property
|
ReportFiles
|
string[]
|
Output | Exposes report files such as renaming HTML report and removal reports. |
SatelliteAssemblies
|
string[]
|
Output | Exposes satellite assemblies associated with output assemblies. The PreEmptive.Dotfuscator.targets file exposes this property as an output Item named DotfuscatedSatelliteAssemblies. |