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
<PackageReference Include="Humbatt.MSBuild.Obfuscar" Version="2.2.50.1"> <PrivateAssets>all</PrivateAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets> </PackageReference>
<PackageVersion Include="Humbatt.MSBuild.Obfuscar" Version="2.2.50.1" />
<PackageReference Include="Humbatt.MSBuild.Obfuscar"> <PrivateAssets>all</PrivateAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets> </PackageReference>
paket add Humbatt.MSBuild.Obfuscar --version 2.2.50.1
#r "nuget: Humbatt.MSBuild.Obfuscar, 2.2.50.1"
#:package Humbatt.MSBuild.Obfuscar@2.2.50.1
#addin nuget:?package=Humbatt.MSBuild.Obfuscar&version=2.2.50.1
#tool nuget:?package=Humbatt.MSBuild.Obfuscar&version=2.2.50.1
Humbatt.MSBuild.Obfuscar
MSBuild targets that run Obfuscar after every Release build, on Windows, Linux and macOS.
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.exeunder Mono. - They looked for the tools in
Obfuscar/<version>while NuGet stores them asobfuscar/<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).
Learn more about Target Frameworks and .NET Standard.
-
.NETStandard 2.0
- Obfuscar (>= 2.2.50)
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.