Home - Forums-.NET - Spices.Net - MSBuild integration questions

Spices.Net

NET code security, tools to protect, obfuscate, tamper defense, code and data safety, recover, convert, optimize, explore, browse and analyze .Net software.

This forum related to following products: Spices.Net Suite, Spices.Net Obfuscator, Spices.Net Decompiler

MSBuild integration questions
Link Posted: 12-Jul-2018 02:11
I've some questions about MSBuild integration:

  1. How to set Members properties? In the help file it explains how to set obfuscation tasks and gives this example:
    <Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
        <UsingTask TaskName="Obfuscator"  AssemblyFile="C:\Program Files\9Rays.Net\Spices5\Bin\NineRays.Build.Tasks.dll"/>
        <Target Name="Spices.Obfuscator">
            <Obfuscator
              InputFiles="$(TargetFileName)"
              Options_Members="KeepsInheritance"
              Options_Naming="NonDisplayable"
              Options_Anonymizer="Minimum"
              Options_MixDictionary="true"
              Options_StringEncryptionMode="Encrypt3DES"
              Options_antiILDASM="True"
              StrongNameKeyFile="..\myKeyFile.snk" />
        </Target>
    </Project>

    But how to I set the Options_Members properties? For example, if i wanted to set ComImport=True then would I do that like this:
    Options_Members="KeepsInheritance, ComImport"

  2. If I set multiple assemblies to be obfuscated in a single project, will cross obfuscation be automatically used? Is the possible in MSBuild?
  3. How do obfuscate assemblies on release mode only?
Link Posted: 12-Jul-2018 02:30

  1. You can use Spices.Net or utility to form Members​ string - the string generated in Members property in property grid can be used in Options_Members, so "KeepInheritance, ComImport" is correct.
  2. ​Yes, cross obfuscation will be used automatically.
    • For VSIP: To use conditional obfuscation, please use ​Spices_ConfigurationsToObfuscate property in solution's properties. Here you can define configurations to obfuscate. For example: "Release;Release_Test" turn obfuscation on just for Release and Release_Test configurations.
    • For MSBuild: you can use MSBuild conditions attribute (https://docs.microsoft.com/en-us/visualstudio/msbuild/msbuild-conditions), for example:

      <Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
          <UsingTask TaskName="Obfuscator"
              AssemblyFile="C:\Program Files\9Rays.Net\Spices5\Bin\NineRays.Build.Tasks.dll"/>
          <Target Name="Spices.Obfuscator"
        Condition="'$(Configuration)' == 'Release'">
              <Obfuscator
                InputFiles="$(TargetFileName)"
                Options_Members="KeepsInheritance"
                Options_Naming="NonDisplayable"
                Options_Anonymizer="Minimum"
                Options_MixDictionary="true"
                Options_StringEncryptionMode="3DES"
                Options_antiILDASM="True"
                StrongNameKeyFile="..\myKeyFile.snk" />
          </Target>
      </Project>
      This definition of task will be used just in Release configuration.​