I'd like to have a try on this program but I couldn't figure out how to use it.
I've search on the author's site https://github.com/yck1509/ConfuserEx but the example on this site is not clear enough for someone new to the programming like me.
So I post my question in here in hope that someone would show me how to use it in plain English and along with some examples. It would be so great and appreciated very much.
Get the lastest binaries version from here : https://github.com/mkaring/ConfuserEx/releases
Confuser.CLI.exe myProjectFile.crproj
Project file example :
<?xml version="1.0" encoding="utf-8"?>
<project baseDir="c:\" outputDir="c:\Confused" xmlns="http://confuser.codeplex.com">
<rule preset="none" pattern="true">
<protection id="anti debug" />
<protection id="anti dump" />
<protection id="anti ildasm" />
<protection id="anti tamper" />
<protection id="constants" />
<protection id="ctrl flow" />
<protection id="invalid metadata" />
<protection id="ref proxy" />
<protection id="rename" />
<protection id="resources" />
</rule>
<module path="ICSharpCode.AvalonEdit.dll" />
<module path="ICSharpCode.Decompiler.dll" />
<module path="ICSharpCode.NRefactory.dll" />
<module path="ICSharpCode.NRefactory.CSharp.dll" />
<module path="ICSharpCode.NRefactory.VB.dll" />
<module path="ICSharpCode.TreeView.dll" />
<module path="ILSpy.BamlDecompiler.Plugin.dll" />
<module path="ILSpy.exe" />
<module path="ILSpy.SharpDevelop.LGPL.dll" />
<module path="Mono.Cecil.dll" />
<module path="Mono.Cecil.Pdb.dll" />
</project>
Config file format : https://github.com/yck1509/ConfuserEx/blob/master/docs/ProjectFormat.md
This answer cover the cases when you have a solution with (A) multiple projects that may reference each other, and (B) you're looking to automate obfuscation in a Visual Studio Setup project.
1) Add on each of your projects a Confuser.crproj text file, in the project's folder directly. In this folder you should see inside the "bin", "ob", "resources", etc. folders. There is no need to attach these files to your solution in visual studio. The text file should look like this:
<?xml version="1.0" encoding="utf-8"?>
<project baseDir="obj\Release" outputDir="..\Release" xmlns="http://confuser.codeplex.com">
<rule preset="none" pattern="true">
<protection id="anti debug" />
<protection id="anti dump" />
<protection id="anti ildasm" />
<protection id="anti tamper" />
<protection id="constants" />
<protection id="ctrl flow" />
<protection id="invalid metadata" />
<protection id="ref proxy" />
<protection id="resources" />
</rule>
<module path="MyLibrary.dll" />
<probePath>..\..\bin\Release</probePath>
</project>
Replace MyLibrary.dll for the output of your project. (And replace .dll for .exe if it's an executable.)
ConfuserEX chooses different starting points for relative paths so that's why the paths look weird in the file.
The key element of this step is to obfuscate the "obj" output of each of your projects. This is to help your Windows Setup project to pick up the obfuscated versions.
2) In the post-build event of each of your projects, add a post-build event like the following:
if "$(ConfigurationName)" == "Release" $(SolutionDir)..\ConfuserEX\Confuser.CLI.exe $(ProjectDir)Confuser.crproj
The first condition is to obfuscate only when building in Release. Here you will need to adjust the paths to match the path of your Confuser.CLI.exe. I have my ConfuserEX folder alongside the solution's root folder.
3) In your Setup project, the issue we need to address is to make sure that packaging picks up your obfuscated versions. Setup has some obscure logic to decide from which folder each assembly is picked up. We will force it to pick up the right ones. For this, you have to:
(3a) add all your projects as "Project Output", this makes sure the obfuscated files in your "obj" folders make it to the package.
(3b) check the "detected dependencies" section of your Setup project. Whenever you see a dependency that is generated by one of your projects, go to its Properties and mark it as Exclude=True. This makes sure your obfuscated versions in the package aren't replaced by non-obfuscated versions due to the inference process.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With