Support Corner: Config Properties in Dotfuscator

Enterprise application development is a complex process that involves various elements. Throughout our Support Corner discussions, we have talked about how PreEmptive offers flexibility to cater to different use cases. Config Properties is a feature that enables Dotfuscator Projects to run in different build environments without the need for hard-coded paths or file names.

Creating Relative Paths

With Dotfuscator’s Visual Studio integration, relative paths are automatically generated for all inputs. This allows builds to be triggered in local development environments and then run on build automation platforms like Azure DevOps, Jenkins, GitLab, etc., without the need to update paths.

Sometimes, it may be preferable to run Dotfuscator as a separate step, using the GUI or command line interface. In such cases, relative paths can be created using the “configdir” token.

For example, if a path is stored in the configuration file as:

<file dir=" c:devmyprojectbinRelease" name="MyApp.exe" />

This can be made relative to the Dotfuscator configuration file:

<file dir="${configdir}binRelease" name="MyApp.exe" />

Defining Properties

To define your own properties in Dotfuscator, you can navigate to the Settings tab and select Config Properties. For instance, you can create a property named “myassemblydir” and assign a path to the location of the assembly file. This property will then appear in the configuration file as follows:

<dotfuscator version="2.3">

  <propertylist>

    <property name="myassemblydir" value="c:path_to_ myassemblydir" />

  </propertylist>

Making Assembly Files Relative

You can make project assembly files relative like this:

<file dir="${myassemblydir}" name="MyDll.dll"/>
<file dir="${myassemblydir}" name="MyOtherDll.dll"/>

This property can be dynamically expanded at build time, if we want to override the configuration file setting:

>dotfuscator.exe /p= myassemblydir =”c:dynamic_path_to_ myassemblydir” C:MyDotfuscatorProjectsDotfuscatorConfig.xml

Get the Most From Dotfuscator With Config Properties

You can use Config Properties to define directories (input, output, temp directory or key file directory) and name elements (assembly file, strong name key file names). This provides flexibility to run builds from multiple environments without having to update project files.

If you have any feedback on this topic or other topics you would like us to discuss in the Support Corner, please contact our Support Department.