How to use ConfuserEx?

后端 未结 4 1015
情话喂你
情话喂你 2021-01-30 03:22

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 examp

4条回答
  •  日久生厌
    2021-01-30 04:04

    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:

    
    
        
            
            
            
            
            
            
            
            
            
        
        
        ..\..\bin\Release
    
    

    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.

提交回复
热议问题