We've come up with a way to automate .NET code obfuscation using the Dotfuscator Community Edition provided with Visual Studio .NET 2003 and the post build action of our C# projects.
We're able to use the Visual Studio Macros to locate the path and name of the recently built assembly, obfuscate that assembly into a temporary directory, copy the obfuscated assembly over the original, then cleanup our temporary files. The effect is almost as if the IDE and compilier performed the obfuscation automatically.
Here's the post build action commands that make this happen:
"C:\Program Files\Microsoft Visual Studio .NET 2003\PreEmptive Solutions\Dotfuscator Community Edition\dotfuscator.exe" /q /p=SourceDirectory=$(TargetDir),SourceFile=$(TargetFileName) $(ProjectDir)Dotfuscator.xml
copy $(TargetDir)Dotfuscator\$(TargetFileName) $(TargetDir)$(TargetFileName)
rmdir /S /Q $(TargetDir)Dotfuscator
You will need to create a Dotfuscator.xml file similar to the one listed below in the root of your project folder.
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<!DOCTYPE dotfuscator SYSTEM "http://www.preemptive.com/dotfuscator/dtd/dotfuscator_v1.1.dtd">
<dotfuscator version="1.1">
<propertylist>
<property name="SourceDirectory" value="This Path Will Be Replaced By Visual Studio" />
<property name="SourceFile" value="This Filename Will Be Replaced By Visual Studio" />
</propertylist>
<trigger>
<filelist>
<file dir="${SourceDirectory}\" name="${SourceFile}" />
</filelist>
</trigger>
<output>
<file dir="${SourceDirectory}\Dotfuscator\" />
</output>
</dotfuscator>