How to install and use obfuscar?

前端 未结 5 463
情深已故
情深已故 2020-12-23 15:28

I just finished my C# project(WPF), but now I meet problems on using \"obfuscar\" (another applicaion would be welcome, if easier to use).

Of course I looked already

相关标签:
5条回答
  • 2020-12-23 15:33
    1. Download the Obfuscar.Console.exe you can download from Nuget, then unzip obfuscar.versionnumber.nupkg, and find the exe.
    2. Besides exe, create one input folder and one output folder. put BasicExemple.exe into input folder.
    3. Besides exe, create plain text file(config.xml for example), and the contents can be very simple:

      <?xml version='1.0'?>
      <Obfuscator>
        <Var name="InPath" value=".\input folder name" />
        <Var name="OutPath" value=".\output folder name" />
        <Module file="$(InPath)\BasicExemple.exe" />
      </Obfuscator>
      
    4. Run cmd, cd to exe's directory, then run Obfuscar.Console.exe config.xml

    5. The output folder will contain the processed binary.

    0 讨论(0)
  • 2020-12-23 15:33

    I set this up to run on the Post Build event in Visual Studio.

    1. Add Obfuscar NuGet Package to your solution.
    2. Add obfuscar.xml file to your project and change Copy to Output Directory: Always. See the post on this thread by vinsa for an XML sample. I had to include the full path to my project in "InPath" variable. Then the obfucasted folder was under bin/[debug / release].

    3. In the Visual Studio post build events enter: "$(Obfuscar)" obfuscar.xml

    0 讨论(0)
  • 2020-12-23 15:41

    From PowerShell as Administator:

    PS> Install-Package Obfuscar
    

    This places the Obfuscar.Console.exe executable in the directory:

    C:\Program Files\PackageManagement\NuGet\Packages\Obfuscar.2.2.9\tools
    

    Change the Version number in the directory name accordingly.

    0 讨论(0)
  • 2020-12-23 15:46

    I have just created an extended configuration file for Obfuscar and would like to share it. Full list of available parameters here

    <?xml version='1.0'?>
    <Obfuscator>
      <Var name="InPath" value="." />
      <Var name="OutPath" value=".\Obfuscator_Output" />
      <Var name="KeepPublicApi" value="false" />
      <Var name="HidePrivateApi" value="true" />
      <Var name="RenameProperties" value="true" />
      <Var name="RenameEvents" value="true" />
      <Var name="RenameFields" value="true" />
      <Var name="UseUnicodeNames" value="true" />
      <Var name="HideStrings" value="true" />
      <Var name="OptimizeMethods" value="true" />
      <Var name="SuppressIldasm" value="true" />
      <Module file="$(InPath)\MyApplication.exe" />
    </Obfuscator>
    
    0 讨论(0)
  • 2020-12-23 15:53

    In order to use it on a .Net Core 2.1 console app, you can do this:

    1 - Install Obfuscar by executing the following command in a console window:

    dotnet tool install --global Obfuscar.GlobalTool --version 2.2.18

    (you can check the last version here: https://www.nuget.org/packages/Obfuscar.GlobalTool)

    2 - Add an XML file to the project you want to obfuscate called obfuscar.xml with the following content (from @vinsa answer):

    <?xml version='1.0'?>
    <Obfuscator>
    <Var name="InPath" value=".\bin\Release\netcoreapp2.1\linux-arm\publish" />
    <Var name="OutPath" value="$(InPath)\ReadyForDeployment" />
    <Var name="KeepPublicApi" value="false" />
    <Var name="HidePrivateApi" value="true" />
    <Var name="RenameProperties" value="true" />
    <Var name="RenameEvents" value="true" />
    <Var name="RenameFields" value="true" />
    <Var name="UseUnicodeNames" value="true" />
    <Var name="HideStrings" value="true" />
    <Var name="OptimizeMethods" value="true" />
    <Var name="SuppressIldasm" value="true" />
    <Module file="$(InPath)\YourProject.dll" />
    </Obfuscator>
    

    3 - Finally, right click on your project, then Properties, Build Events, and in the Post-build event text box add this line:

    if $(ConfigurationName) == Release obfuscar.console .\obfuscar.xml
    
    0 讨论(0)
提交回复
热议问题