• ArmDot Home
  • Documentation
  • Tutorial
  • API
  • Download
Show / Hide Table of Contents
  • Getting Started
  • Tutorial
  • MSBuild Obfuscation Task
  • Embedded Files
    • Embedded Files
    • Predefined Directories
  • Key Generators
    • Key Generator for PHP
    • Key Generator for C/C++
  • Command Line Tools
    • ArmDotConsole.exe
  • API
    • ArmDot.Client
      • Api
      • Api.Hardware
      • Api.LicenseKeyState
      • EmbedFileAttribute
      • HideStringsAttribute
      • ObfuscateControlFlowAttribute
      • ObfuscateNamesAttribute
      • ObfuscateNamespacesAttribute
      • ProtectEmbeddedResourcesAttribute
      • VirtualizeCodeAttribute
    • ArmDot.Engine.MSBuildTasks
      • ObfuscateTask
  • Obfuscation Attributes
  • Stack Trace Deobfuscation
  • ArmDot Warnings
    • How to disable a warning?
    • Warning ARMDOT0001
    • Warning ARMDOT0002
    • Warning ARMDOT0003
    • Warning ARMDOT0004
    • Warning ARMDOT0005
    • Warning ARMDOT0006
    • Warning ARMDOT0007
    • Warning ARMDOT0008
  • Glossary
    • Hardware Id
  • License
  • Activation

Class ObfuscateTask

This is an MSBuild task to automate obfuscation using ArmDot.

Read more about how to use ObfuscateTask to obfuscate assemblies while building a project.

Inheritance
System.Object
ObfuscateTask
Implements
ArmDot.Engine.Builder.IAsyncOperationEvents
Namespace: ArmDot.Engine.MSBuildTasks
Assembly: ArmDot.Engine.MSBuildTasks.dll
Syntax
public class ObfuscateTask : Build.Utilities.Task, IAsyncOperationEvents

Properties

EmbeddedFiles

This parameter is optional.

Inputs stores a list of files to embed.

Notes: use %24 to encode $

For example, use %24(AssemblyDirectory) to encode $(AssemblyDirectory)

<ItemGroup>
  <FilesInfo Include="$(TargetDir)Embed\virtual_file_content2.txt">
    <RuntimePath>%24(AssemblyDirectory)\embedded_file2.txt</RuntimePath>
  </FilesInfo>
  <FilesInfo Include="$(TargetDir)Embed\virtual_file_content3.txt">
    <RuntimePath>%24(AssemblyDirectory)\embedded_file3.txt</RuntimePath>
  </FilesInfo>
</ItemGroup>

<Target Name="Protect" AfterTargets="AfterCompile" BeforeTargets="BeforePublish">
  <ItemGroup>
     <Assemblies Include="$(ProjectDir)$(IntermediateOutputPath)$(TargetFileName)" />
  </ItemGroup>
  <ArmDot.Engine.MSBuildTasks.ObfuscateTask
    Inputs="@(Assemblies)"
    EmbeddedFiles="@(FilesInfo)"
    ReferencePaths="@(_ResolveAssemblyReferenceResolvedFiles->'%(RootDir)%(Directory)')"
    SkipAlreadyObfuscatedAssemblies="true"
  />
</Target>
Declaration
public ITaskItem[] EmbeddedFiles { get; set; }
Property Value
Type Description
ITaskItem[]

Inputs

This parameter is required.

Inputs stores a list of assemblies to protect:

<Target Name="Protect" AfterTargets="AfterCompile" BeforeTargets="BeforePublish">
  <ItemGroup>
     <Assemblies Include="$(ProjectDir)$(IntermediateOutputPath)$(TargetFileName)" />
  </ItemGroup>
  <ArmDot.Engine.MSBuildTasks.ObfuscateTask
     Inputs="@(Assemblies)"
     ReferencePaths="@(_ResolveAssemblyReferenceResolvedFiles->'%(RootDir)%(Directory)')"
     SkipAlreadyObfuscatedAssemblies="true"
  />
</Target>

Also, Inputs can contain options for an assembly.

The following options are available:

KeyFile specifies the path to the file containing the key pair, which is used to generate a strong name. If specified, ArmDot signs the assembly after obfuscation using the specified file. Use this option if an assembly is a strong-named one. Obfuscation modifies an assembly making a strong name signature not valid. That is why signing is required:

<Target Name="Protect" AfterTargets="AfterCompile" BeforeTargets="BeforePublish">
  <ItemGroup>
     <Assemblies
       Include="$(ProjectDir)$(IntermediateOutputPath)$(TargetFileName)"
       KeyFile="key.snk"
     />
  </ItemGroup>
  <ArmDot.Engine.MSBuildTasks.ObfuscateTask
     Inputs="@(Assemblies)"
     ReferencePaths="@(_ResolveAssemblyReferenceResolvedFiles->'%(RootDir)%(Directory)')"
     SkipAlreadyObfuscatedAssemblies="true"
  />
</Target>
Declaration
public ITaskItem[] Inputs { get; set; }
Property Value
Type Description
ITaskItem[]

License

This parameter is deprecated.

Declaration
public string License { get; set; }
Property Value
Type Description
System.String

LicenseFile

This parameter is optional.

Set it to a file that stores a purchased ArmDot license key.

If LicenseFile is not set, ArmDot tries to read a license key from the default location. If it fails, ArmDot works in the demo mode.

Declaration
public string LicenseFile { get; set; }
Property Value
Type Description
System.String

MapFile

This parameter is optional.

This parameter tells ArmDot writes information about original and obfuscated names to the specified file.

Map files are used to deobfuscate stack traces.

Example:

<Target Name="Protect" AfterTargets="AfterCompile" BeforeTargets="BeforePublish">
  <ItemGroup>
     <Assemblies Include="$(ProjectDir)$(IntermediateOutputPath)$(TargetFileName)" />
  </ItemGroup>
  <ArmDot.Engine.MSBuildTasks.ObfuscateTask
     Inputs="@(Assemblies)"
     MapFile="map.xml"
     SkipAlreadyObfuscatedAssemblies="true"
  />
</Target>
Declaration
public string MapFile { get; set; }
Property Value
Type Description
System.String

NoWarn

This parameter is optional.

Suppresses the ArmDot's ability to generate warnings.

NoWarn specifies warning number or numbers.

If you specify multiple warning numbers, separate them with a comma:

<Target Name="Protect" AfterTargets="AfterCompile" BeforeTargets="BeforePublish">
  <ItemGroup>
     <Assemblies Include="$(ProjectDir)$(IntermediateOutputPath)$(TargetFileName)" />
  </ItemGroup>
  <ArmDot.Engine.MSBuildTasks.ObfuscateTask
    Inputs="@(Assemblies)"
    NoWarn="4"
    ReferencePaths="@(_ResolveAssemblyReferenceResolvedFiles->'%(RootDir)%(Directory)')"
    SkipAlreadyObfuscatedAssemblies="true"
  />
</Target>
Declaration
public string NoWarn { get; set; }
Property Value
Type Description
System.String

ProjectPath

This parameter is optional.

ProjectPath specifies a path to a project file that is used to store cryptography constants to generate license keys, and blacklisted license keys.

If ProjectPath doesn't exist, a new project file is created.

Declaration
public string ProjectPath { get; set; }
Property Value
Type Description
System.String

ReferencePaths

This parameter is optional.

ReferencePaths stores a list of directories to find referenced assemblies.

Sometimes ArmDot needs to find an assembly referenced by the assembly which is being protected.

To help ArmDot locate such an assembly, use ReferencePaths:

<Target Name="Protect" AfterTargets="AfterCompile" BeforeTargets="BeforePublish">
  <ItemGroup>
     <Assemblies Include="$(ProjectDir)$(IntermediateOutputPath)$(TargetFileName)" />
  </ItemGroup>
  <ItemGroup>
    <ReferencePaths Include="C:\MyAssemblies" />
    <ReferencePaths Include="@(_ResolveAssemblyReferenceResolvedFiles->'%(RootDir)%(Directory)')" />
  </ItemGroup>
  <ArmDot.Engine.MSBuildTasks.ObfuscateTask
    Inputs="@(Assemblies)"
    ReferencePaths="@(ReferencePaths)"
    SkipAlreadyObfuscatedAssemblies="true"
  />
</Target>
Declaration
public ITaskItem[] ReferencePaths { get; set; }
Property Value
Type Description
ITaskItem[]

SkipAlreadyObfuscatedAssemblies

This parameter is optional.

This parameter tells ArmDot not to obfuscate assemblies that are obfuscated already.

Declaration
public bool SkipAlreadyObfuscatedAssemblies { get; set; }
Property Value
Type Description
System.Boolean

TreatAllWarningsAsErrors

This parameter is optional.

This parameter tells ArmDot to treat all warnings as errors. Because an error occurred, no obfuscated assembly was generated:

<Target Name="Protect" AfterTargets="AfterCompile" BeforeTargets="BeforePublish">
  <ItemGroup>
     <Assemblies Include="$(ProjectDir)$(IntermediateOutputPath)$(TargetFileName)" />
  </ItemGroup>
  <ArmDot.Engine.MSBuildTasks.ObfuscateTask
    Inputs="@(Assemblies)"
    TreatAllWarningsAsErrors="true"
    ReferencePaths="@(_ResolveAssemblyReferenceResolvedFiles->'%(RootDir)%(Directory)')"
    SkipAlreadyObfuscatedAssemblies="true"
  />
</Target>
Declaration
public bool TreatAllWarningsAsErrors { get; set; }
Property Value
Type Description
System.Boolean

Methods

Execute()

You never call this method.

Declaration
public override bool Execute()
Returns
Type Description
System.Boolean

OnError(String)

You never call this method.

Declaration
public void OnError(string text)
Parameters
Type Name Description
System.String text

OnFinished(Exception)

You never call this method.

Declaration
public void OnFinished(Exception error)
Parameters
Type Name Description
System.Exception error

OnInfo(String)

You never call this method.

Declaration
public void OnInfo(string text)
Parameters
Type Name Description
System.String text

OnProgress(Int32)

You never call this method.

Declaration
public void OnProgress(int percent)
Parameters
Type Name Description
System.Int32 percent

OnWarning(BaseWarning)

You never call this method.

Declaration
public void OnWarning(BaseWarning warning)
Parameters
Type Name Description
ArmDot.Engine.Warnings.BaseWarning warning

Implements

ArmDot.Engine.Builder.IAsyncOperationEvents
Back to top Copyright © 2015-2017 Microsoft
Generated by DocFX