ricaun.Obfuscar 1.3.0

Prefix Reserved
dotnet add package ricaun.Obfuscar --version 1.3.0
                    
NuGet\Install-Package ricaun.Obfuscar -Version 1.3.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="ricaun.Obfuscar" Version="1.3.0">
  <PrivateAssets>all</PrivateAssets>
  <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="ricaun.Obfuscar" Version="1.3.0" />
                    
Directory.Packages.props
<PackageReference Include="ricaun.Obfuscar">
  <PrivateAssets>all</PrivateAssets>
  <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add ricaun.Obfuscar --version 1.3.0
                    
#r "nuget: ricaun.Obfuscar, 1.3.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package ricaun.Obfuscar@1.3.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=ricaun.Obfuscar&version=1.3.0
                    
Install as a Cake Addin
#tool nuget:?package=ricaun.Obfuscar&version=1.3.0
                    
Install as a Cake Tool

ricaun.Obfuscar

Visual Studio 2026 Nuke License MIT Build Release

ricaun.Obfuscar is a basic obfuscator for .NET assemblies. Uses the package Obfuscar to obfucate the assembly using Target to replate the original dll to the obfuscate dll.

By default the obfuscar target execute before CopyFilesToOutputDirectory to replace the IntermediateAssembly file.

Installation

Install the package using the NuGet package manager or using PackageReference.

<PackageReference Include="ricaun.Obfuscar" Version="*">
  <PrivateAssets>all</PrivateAssets>
  <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>

By default the obfuscar is enabled when the package is used, and the KeepPublicApi, HidePrivateApi, AnalyzeXaml and SkipGenerated options are set to true.

Is possible to use the [System.Reflection.Obfuscation] to disable the obfuscation in some classes.

Version

The package Obfuscar with version 2.2.50 is used by default to repack the assembly, if the your project contains a different version, the package will use the version from the package.

<PackageReference Include="Obfuscar" Version="*">
  <PrivateAssets>all</PrivateAssets>
  <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>

Configuration

PropertyGroups

Property Name Default Value Description
ObfuscarEnabled true Enable / Disable Obfuscar task.
ObfuscarFileName obfuscar.xml Obfuscar configuration file name.
ObfuscarFolderName Obfuscar Obfuscar folder to release obfuscar files.
ObfuscarConfiguration See below Default configuration in the obfuscar.xml file.
ObfuscarContent Extra configuration to add in the obfuscar.xml file.
ObfuscarContentModule Extra configuration to add inside the module in the obfuscar.xml file.
ObfuscarPathReferencesEnabled true Add the references folder to the ObfuscarPathReferences to search path in the obfuscar.xml file.
ObfuscarImportance High Log importance to show the main obfuscar. (Low or High)
ObfuscarCopyImportance Low Log importance to show in the console. (Low or High)
ObfuscarCommandImportance Low Log importance from the Obfuscar.exe to show in the console. (Low or High)
ObfuscarAfterTargets Target to run obfuscation after.
ObfuscarBeforeTargets CopyFilesToOutputDirectory Target to run obfuscation before.
<PropertyGroup>
  <ObfuscarEnabled>true</ObfuscarEnabled>
  <ObfuscarFileName>obfuscar.xml</ObfuscarFileName>
  <ObfuscarFolderName>Obfuscar</ObfuscarFolderName>
  <ObfuscarContent></ObfuscarContent>
  <ObfuscarPathReferencesEnabled>true</ObfuscarPathReferencesEnabled>
  <ObfuscarImportance>High</ObfuscarImportance>
</PropertyGroup>

Default obfuscar.xmlfile

The default obfuscar.xml file is created using the template:

<?xml version='1.0'?>
<Obfuscator>
  <Var name="InPath" value="$(ObfuscarTargetDirectory)" />
  <Var name="OutPath" value="$(ObfuscarTargetDirectory)$(ObfuscarFolderName)" />
  $(ObfuscarConfiguration)
  $(ObfuscarPathReferences)
  $(ObfuscarContent)
  <Module file="$(ObfuscarTargetDirectory)$(ObfuscarFileName)">
  $(ObfuscarContentModule)
  </Module>
</Obfuscator>

The ObfuscarConfiguration property is used to add the default configuration to the obfuscar.xml file.

This is the default configuration (KeepPublicApi, HidePrivateApi, AnalyzeXaml, SkipGenerated)

<ObfuscarConfiguration>
<![CDATA[
<Var name="KeepPublicApi" value="true" />
<Var name="HidePrivateApi" value="true" />
<Var name="AnalyzeXaml" value="true" />
<Var name="SkipGenerated" value="true" />
]]>
</ObfuscarConfiguration>

The ObfuscarContent property is used to add extra configuration to the obfuscar.xml file.

This disable the obfuscation in private members

<ObfuscarContent>
<![CDATA[
<Var name="HidePrivateApi" value="false" />
]]>
</ObfuscarContent>

The ObfuscarContentModule property is used to add extra configuration in the module to the obfuscar.xml file.

This skip all types with the CompilerGeneratedAttribute attribute and methods inside.

<ObfuscarContentModule>
<![CDATA[
<SkipType name="*" decoratorAll="System.Runtime.CompilerServices.CompilerGeneratedAttribute" skipMethods="true" />
]]>
</ObfuscarContentModule>

Strong-Naming

If the assembly is strong-named, is necessary to add the KeyFile to the obfuscar.xml file using the ObfuscarContent property.

<ObfuscarContent Condition="$(SignAssembly)">
<![CDATA[
$(ObfuscarContent)
<Var name="KeyFile" value="$(AssemblyOriginatorKeyFile)" />
]]>
</ObfuscarContent>

Project Reference

This project use the same approach as the ricaun.ILRepack project.

License

This project is licensed under the MIT License.


Do you like this project? Please star this project on GitHub!

There are no supported framework assets in this package.

Learn more about Target Frameworks and .NET Standard.

  • .NETFramework 4.0

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.3.0 219 7/9/2026
Loading failed