Humbatt.MSBuild.Obfuscar 2.2.50.1

dotnet add package Humbatt.MSBuild.Obfuscar --version 2.2.50.1
                    
NuGet\Install-Package Humbatt.MSBuild.Obfuscar -Version 2.2.50.1
                    
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="Humbatt.MSBuild.Obfuscar" Version="2.2.50.1">
  <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="Humbatt.MSBuild.Obfuscar" Version="2.2.50.1" />
                    
Directory.Packages.props
<PackageReference Include="Humbatt.MSBuild.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 Humbatt.MSBuild.Obfuscar --version 2.2.50.1
                    
#r "nuget: Humbatt.MSBuild.Obfuscar, 2.2.50.1"
                    
#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 Humbatt.MSBuild.Obfuscar@2.2.50.1
                    
#: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=Humbatt.MSBuild.Obfuscar&version=2.2.50.1
                    
Install as a Cake Addin
#tool nuget:?package=Humbatt.MSBuild.Obfuscar&version=2.2.50.1
                    
Install as a Cake Tool

Humbatt.MSBuild.Obfuscar

MSBuild targets that run Obfuscar after every Release build, on Windows, Linux and macOS.

Build NuGet

Usage

<PackageReference Include="Humbatt.MSBuild.Obfuscar" Version="2.2.50.1" PrivateAssets="all" />

Put an Obfuscar configuration next to the project, named <ProjectName>.xml or Obfuscar.xml. Write its output to obfuscated under the build output, using forward slashes so it works on every OS:

<Obfuscator>
  <Var name="InPath" value="bin/Release/netstandard2.0" />
  <Var name="OutPath" value="$(InPath)/obfuscated" />
  <Var name="HidePrivateApi" value="true" />
  <Module file="$(InPath)/MyLibrary.dll" />
</Obfuscator>

After a Release build the obfuscated files replace the originals in the output folder, so dotnet pack packs them. Mapping.txt is left beside them.

Property Meaning
ObfuscarRunner dotnet (default): Obfuscar's cross-platform console, bundled in the package and run by the build's .NET host (.NET 10 or later). exe: Obfuscar.Console.exe from the Obfuscar package (.NET Framework: Windows, or Mono elsewhere), as in versions before 2.2.50.
SkipObfuscation true builds without obfuscating.
ObfuscarConfigFile A different configuration file.

Strong-name signing (<Var name="KeyFile" .../>) works with both runners.

What changed in 2.2.50

Earlier versions only worked on Windows:

  • Off Windows they ran Obfuscar.Console.exe under Mono.
  • They looked for the tools in Obfuscar/<version> while NuGet stores them as obfuscar/<version>.
  • Off Windows they never moved the obfuscated files into the output, so packages were built from the unobfuscated assemblies without any error.

2.2.50 fixes all three. It also no longer overwrites MSBuild's ProjectFileName property; use ObfuscarConfigFile instead.

Building and releasing

./test.sh                          # pack, obfuscate the sample, and check the result
./test.sh -p:ObfuscarRunner=exe    # the same with Obfuscar.Console.exe (Windows)

GitHub Actions: ci.yml runs test.sh on Linux, Windows and macOS for every pull request (and pushes to develop), so a change is checked before it merges. release.yml publishes.

To release, bump <Version> in MSBuild.Obfuscar/Humbatt.MSBuild.Obfuscar.csproj and merge to main. The workflow then packs the package, pushes it to nuget.org with Trusted Publishing (no API key stored; the nuget environment and NUGET_USER secret), tags it v<version>, and creates a GitHub release with the package attached. A version that is already published is skipped.

Obfuscar

Obfuscar is an open-source .NET obfuscator released under the MIT license. Its console is bundled in this package; see THIRD-PARTY-NOTICES.txt.

License

MIT; see LICENSE. Originally by Enner Pérez (ennerperez/msbuild-obfuscar).

There are no supported framework assets in this package.

Learn more about Target Frameworks and .NET Standard.

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
2.2.50.1 112 11/5/2026
2.2.28.21802 2,564 9/22/2020
2.2.28.21261 1,154 9/22/2020
2.2.26 1,181 9/21/2020

Works on Linux and macOS: runs Obfuscar's cross-platform console (bundled, Obfuscar 2.2.50) with the build's .NET host, finds the Obfuscar package in lower-case NuGet folders, and replaces the output with the obfuscated files on every OS. Set ObfuscarRunner=exe for the previous Obfuscar.Console.exe behaviour, SkipObfuscation=true to turn it off.