Command Line Interface
Here we explain how to use Dotfuscator's command line interface. For a complete reference on the available options see the Command Line Reference page.
The command line interface is designed to allow you to:
- Run a Dotfuscator build with an existing config file, for example on a build server.
- Protect your application without requiring creation of a config file.
- Override or supplement options in an existing config file.
- Create a config file.
Locating the Command Line Executable
The name of the Dotfuscator command line executable is dotfuscator.exe
It is available in the installation directory, which is provided by the environment variable DOTFUSCATOR_HOME
.
If possible, the installer adds %DOTFUSCATOR_HOME%
to the PATH, so in most cases you can just run dotfuscator
from the command line unqualified.
DOTFUSCATOR_HOME
environment variable will not be available in this scenario.
Building from the Command Line
The primary use for the Dotfuscator command line program is running a Dotfuscator build when you already have a config file. This is very easy to do:
dotfuscator config.xml
Saving a Config File from the Command Line
Once you have the command line settings that you want for your application, you can save a config file containing those settings by using the /genconfig
option.
This takes all your command line options, merges them with your configuration template if you have one, and saves a custom config file that you can use for future runs.
Example:
dotfuscator -in:my.dll -keep:namespace -enha:on -cont:high -genconfig:new.xml myconfig.xml
The resulting config file (new.xml
) shows the command line options merged with the options from the original configuration (myconfig.xml
):
Config File:
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<!DOCTYPE dotfuscator SYSTEM "http://www.preemptive.com/dotfuscator/dtd/dotfuscator_v2.2.dtd">
<dotfuscator version="2.2">
<input>
<asmlist>
<inputassembly>
<option>library</option>
<file dir="." name="my.dll" />
</inputassembly>
</asmlist>
</input>
<output>
<file dir="C:\MSProjects\dotfuscatortest\Dotfuscated" />
</output>
<renaming>
<option>enhancedOI</option>
<option>keepnamespace</option>
<mapping>
<mapoutput overwrite="true">
<file dir="${configdir}\reports" name="MyMap.xml" />
</mapoutput>
</mapping>
</renaming>
<controlflow level="high" />
</dotfuscator>
Examples
The following examples use this config file that enables renaming with an output mapping file.
It is referenced as myconfig.xml
in the examples.
Example 1:
<?xml version="1.0"?>
<!DOCTYPE dotfuscator SYSTEM "http://www.preemptive.com/dotfuscator/dtd/dotfuscator_v2.2.dtd">
<dotfuscator version="2.2">
<renaming>
<mapping>
<mapoutput overwrite="true">
<file dir="${configdir}\reports" name="MyMap.xml"/>
</mapoutput>
</mapping>
</renaming>
</dotfuscator>dotfuscator -in:my.dll myconfig.xml
This command specifies my.dll
as an input assembly in library mode (because of the DLL extension), and applies the renaming options in the config file.
In this case, control flow, string encryption, and removal are disabled because they are implicitly disabled in the config file.
The output DLL will go in a directory called ".\Dotfuscated", since an output is not specified in the config file or on the command line.
Example 2:
dotfuscator -in:my.dll -keep:namespace -enha:on -cont:high myconfig.xml
This command also specifies my.dll
as an input assembly.
In addition, it tells the renamer to keep namespaces and use enhanced overload induction.
It also enables control flow obfuscation, setting the level to "high" for maximum obfuscation.