MSBuild Reference
To learn more about using Dotfuscator with MSBuild see the MSBuild Interface page.
Install Location
The targets and tasks provided by Dotfuscator are installed into the following sub-directories of the MSBuild extensions directory:
$(MSBuildExtensionsPath)\PreEmptive\Dotfuscator\<major>
$(MSBuildExtensionsPath)\PreEmptive\Dotfuscator\<major>\<major>.<minor>
$(MSBuildExtensionsPath)\PreEmptive\Dotfuscator\<major>\<major>.<minor>\<major>.<minor>.<patch>
For example, if version 4.99.0 of Dotfuscator is installed, you will see the following directories:
$(MSBuildExtensionsPath)\PreEmptive\Dotfuscator\4
$(MSBuildExtensionsPath)\PreEmptive\Dotfuscator\4\4.99
$(MSBuildExtensionsPath)\PreEmptive\Dotfuscator\4\4.99\4.99.0
The layout is designed so that when writing your own MSBuild files you can point to the most specific version desired. For more information see the section on Side by Side Installs.
Targets Reference
Dotfuscator's MSBuild targets, PreEmptive.Dotfuscator.Common.targets, make it easy to integrate Dotfuscator into a Visual Studio or MSBuild project. The targets are designed to run Dotfuscator immediately following the assembly build process, before packaging.
Available Properties
The following properties are understood by the Dotfuscator targets.
-
- Determines whether the Dotfuscator integration will run.
- If "true", Dotfuscator will protect the project.
- If "false", Dotfuscator will be skipped for this build.
- Defaults to "false".
- Determines whether the Dotfuscator integration will run.
-
- Path to the Dotfuscator config file, relative to the same directory as the MSBuild project file.
- This file does not need to exist if "DotfuscatorGenerateConfigFileIfMissing" is set to "true".
- Defaults to "DotfuscatorConfig.xml".
DotfuscatorGenerateConfigFileIfMissing
- Determines what happens during a build if the file specified by "DotfuscatorConfigPath" does not exist.
- If "true", Dotfuscator generates a new config file at that path using relevant MSBuild properties.
- If "false", Dotfuscator errors the build.
- Defaults to "true".
- Determines what happens during a build if the file specified by "DotfuscatorConfigPath" does not exist.
-
- Path to a Dotfuscator command line executable.
- Defaults to the default install location for Dotfuscator's command line executable. If you installed Dotfuscator to a different location, you should set this property in your project file. To discover the correct path, see Locating the Command Line Executable.
Note: Do not put quotes around any property value, nor end any with a slash or backslash.
MSBuild Task Reference
Dotfuscator provides an MSBuild interface using tasks defined in PreEmptive.Dotfuscator.Tasks.dll.
There is also a targets template that you can import into your MSBuild scripts, PreEmptive.Dotfuscator.targets. This file is installed into the same directories.
Dotfuscate Task
You can run Dotfuscator from MSBuild using the Dotfuscate task. Below are the properties provided by the Dotfuscate task.
Property | Type | Description |
---|---|---|
ConfigPath |
string |
Required. Write-only. Sets the path to the Dotfuscator config. |
DebugSymbols |
string[] |
Read-only. Exposes PDB files associated with output assemblies. The PreEmptive.Dotfuscator.targets file exposes this property as an output Item named DotfuscatedDebugSymbols |
InputAssemblies |
ITaskItem[] |
Write-only. Sets the input assemblies. Inputs specified in InputAssemblies are merged with the inputs listed in the Dotfuscator config. |
InputManagement |
string |
Write-only. 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 will merge the inputs specified in InputAssemblies and specified in the config. |
MappingFile |
string |
Read-only. Exposes the renaming map file. The PreEmptive.Dotfuscator.targets file exposes this property as an output Item named DotfuscatorMappingFile. |
OutputAssemblies |
string[] |
Read-only. Exposes output assemblies. The PreEmptive.Dotfuscator.targets file exposes this property as an output Item named DotfuscatedAssemblies. |
OutputDirectory |
string |
Write-only. Sets the directory where Dotfuscator will write the output assemblies. This overrides the output directory specified in the Dotfuscator config. |
Properties |
string |
Write-only. Sets user-defined external properties. The string must contain a valid XML element with child elements that represent key/value pairs. For example: <Properties> <Property1>Value1</Property1> <Property2>2</Property2> </Properties> |
ReportFiles |
string[] |
Read-only. Exposes report files such as renaming HTML report and removal reports. |
SatelliteAssemblies |
string[] |
Read-only. Exposes satellite assemblies associated with output assemblies. The PreEmptive.Dotfuscator.targets file exposes this property as an output Item named DotfuscatedSatelliteAssemblies. |
PreMark Task
You can extract watermarks from previously watermarked assemblies using the PreMark task. This provides similar functionality to the command line program Premark.exe included in your Dotfuscator installation directory.
Property | Type | Description |
---|---|---|
InputAssemblyPath |
string |
Required. Read/Write. Gets or sets the path to the Assembly whose watermark you want to extract. |
UsePassphrase |
bool |
Read/Write. |
Passphrase |
string |
Read/Write. Currently, the input assemblies must also be listed in the Dotfuscator config. This is only for interoperation with Visual Studio-generated project files. This may change in the future. |
Watermark |
string |
Read-only. Exposes the extracted watermark string. |