Obfy / Guide
Obfy guide
Obfy protects compiled .NET assemblies, and C# source files, by renaming symbols, encrypting data and adding checks, so the build you ship is harder to read. This guide covers the desktop app first and the command line second.
How to read it:
- First run: Getting started, Files and output, Levels and settings.
- Before you ship: What can break, Reading a stack trace, Troubleshooting and FAQ.
- Automating: Command line, Visual Studio and build systems.
Obfuscation is not confidentiality
String, constant, resource and method body encryption, and native packing, hide values from casual inspection. The key is stored in the output, so anyone who runs or inspects it can recover the content: XOR trivially, AES-256 with a little more effort. Do not ship real secrets such as keys, tokens or credentials in an assembly and rely on obfuscation.
Getting started
What you need. The desktop app runs on Windows and needs the Microsoft Edge WebView2 Runtime. The installer includes it. If it is missing, the app says so and shows where to get it. The command line is obfy. It comes with the desktop app, or you can install it as a .NET tool with dotnet tool install --global Obfy, which needs .NET 10. If both are installed, both register obfy, so keep one of them on your PATH.
Your first run.
- On Files, drop assemblies, a solution or a project onto the window, or choose Add files....
- On Protection, Standard is already selected. It is a good first run.
- Press Obfuscate or Ctrl+Enter. The bar along the bottom says what the run will do, and why it cannot start when it cannot.
- When every file succeeds, Results opens. If any file fails, you stay where you are. Open Results and read the Log tab.
- Run your own tests against the protected build. Test the exact files you ship.
What happens to your files. The desktop app and the command line write protected copies. Without an output folder the copy is named MyApp.obfuscated.dll and sits next to the original. They do not stop you from choosing the input’s own folder as the output, and then the protected file replaces the input. The Visual Studio extension works differently: it replaces the project’s build output (see Visual Studio and build systems).
Files and output
What Obfy accepts
| You add | What happens |
|---|---|
.dll, .exe | A managed assembly, protected as a row in the list. |
.cs | C# source. Only renaming, string encryption and control flow apply to source, using the same switches. |
.sln, .slnx, .csproj, .vbproj, .fsproj | Expands into the built assemblies it finds (see below). |
.json | A saved configuration. Only the first one loads; the others are named in a notice. |
Any other file type is ignored without a message. Add files with Add files... (Ctrl+O), or drop them anywhere on the window. You can also start the app with paths and an output folder: ObfyUI.exe MyApp.dll Lib.dll -o output. A folder given this way applies to that session only and is not remembered.
Solutions and projects
Obfy reads each project and looks for its built output in bin/Release, then bin/Debug. Publish and RID-specific folders are not scanned. A project that targets several frameworks gives one row per framework.
A test project, a project with no built output, a project that cannot be read and an unsupported project type stay in the list as skipped rows with the reason. A skipped row cannot be included, because a project row has no output. Build the project, then choose Clear and add the solution again. If nothing can be included, a “Nothing to protect” notice says so.
When the files come from a solution or project, Obfy also adjusts settings per project:
- Preserve XAML bindings is turned on for WPF, WinForms and MAUI projects.
- A library that no included executable refers to keeps its public names.
- A target runtime left on .NET is set to NativeAOT, Blazor WebAssembly or Unity IL2CPP when the project says so.
- Unity namespaces and ASP.NET MVC attributes are added to the exclusions.
The file list
Each row shows the name, origin (Added or Solution), kind (Assembly, Source or Project), size and status. The checkbox drops a file from the run without removing it. The row menu has Show in folder and Remove. Click a row to select it, Ctrl+click to select more, and press Delete to remove the selection. Clear empties the list.
While a run is going the list is locked. Adding, removing, including, loading a configuration and dropping files are all refused, and a drop shows a notice.
How Obfy treats the included files
The notice under the list says which mode applies.
| Included files | What Obfy does | Written with no output folder | Written to an output folder |
|---|---|---|---|
| One assembly | Protects it on its own. | MyApp.obfuscated.dll next to the input | MyApp.dll in the folder |
One .cs file | Protects it on its own. | Name.obfuscated.cs next to the input | Name.cs in the folder |
Two or more .cs files | Compiles them together as one unit, then protects it. | An obfy-src folder next to the first file | In the folder |
| Two or more assemblies, or anything that came from a solution or project | Protects them together as a closed set, so names they share stay consistent after renaming. | An obfy-out folder next to the first included assembly | In the folder |
| Merge assemblies is on, and two or more assemblies | Merges them into one file, then protects it. | First.obfuscated.dll next to the first assembly | First.obfuscated.dll in the folder |
Closed-set details:
- Merge wins over a closed set. It applies only when every included file is an assembly.
- C# source files in a closed set are skipped, with a warning in the log.
- A library that no executable in the set refers to keeps its public names. If the set has no executable at all, every assembly keeps its public names. Preserve public API forces this for all of them.
- If any assembly fails to load, the whole set stops and nothing is written.
- The set is written once every assembly has been processed.
Merge assemblies is on the Protection screen, under Packaging. Make merged types internal is on by default.
The output box
Leave Output folder empty to use the table above. The box shows what will happen as its placeholder. Type a path or choose Browse.... The folder need not exist yet.
Your last folder and your symbol map choice are remembered between launches in %APPDATA%\Obfy\ui-preferences.json. Clear the box to go back to the default. A remembered folder that no longer exists is cleared, with a warning.
Symbol map
Write a symbol map is off by default. When it is on, Obfy saves a file that maps the new names back to the originals after a run completes. The default is symbolmap.json in the output folder, or next to the first included file when no folder is set. You can type another path, or choose Browse.... A relative path is taken from the output folder. A cancelled run writes no map. Keep the map private, and read Reading a stack trace.
Levels and settings
The four levels
A level is a ready-made set of protections. Each card also shows three small meters: protection, run-time cost and compatibility risk.
| Protection | Minimal | Standard | Aggressive |
|---|---|---|---|
| Symbol renaming | On | On | On |
| Remove debug information | On | On | On |
| Remove attributes | Off | On | On |
| String encryption | Off | On | On |
| Constant encryption | Off | Off | On |
| Resource encryption | Off | Off | On |
| Control flow | Off | Off | On, intensity 80 |
| Reference proxy | Off | Off | On |
| Method body encryption | Off | Off | On |
| Debugger check | Off | Off | On |
| Integrity check | Off | Off | On |
| Memory image guard | Off | Off | On |
| Decompiler resistance | Off | Off | On |
Minimal is the safest. Standard is the recommended start. Aggressive needs careful testing.
Virtualization, native packing, the incremental cache and calls into other libraries through the reference proxy are off at every level. Turning one on moves you to Custom. Embed dependencies, merge, watermark and signing are also off by default, but they belong to no level.
Custom, and the Changed badge
Change any option a level controls and you move to Custom. A Changed badge marks a protection whose switch, or a setting the level controls, differs from the last level card you chose.
- Choose a level card again to switch the protections back to that level. Settings a level does not control keep your values: the string and resource algorithms, the naming style, thresholds and counts, Preserve public API and Preserve XAML bindings.
- Choose Custom to go back to the mix you had when you last left Custom.
- The target runtime, watermark, signing, merge, embedding, the packing target and the scope lists belong to no level. Changing them keeps your level.
Target runtime
Some protections do not work on every runtime. Pick the runtime your app runs on: .NET (desktop or server), NativeAOT, Unity IL2CPP or Blazor WebAssembly. For the last three:
- Method body encryption, memory image guard, virtualization and embed dependencies are switched off in the list. Their settings are kept, so switching back restores them.
- Native packing is switched off when you run, with a warning in the log.
- The debugger check stays available and leaves out its Windows-specific part.
- Other protections stay as you set them. Check each one on the real runtime.
Protect the managed assemblies before the NativeAOT or IL2CPP step, not after.
Configuration files
The Open... and Save buttons on the Protection screen, and Ctrl+L and Ctrl+S, load and save a configuration. The chip beside them shows the file name and whether it has unsaved changes.
- Save writes to the file you opened or last saved. The first time it asks where, and suggests
obfy.json. - Open loads a file. Dropping a
.jsononto the window does the same. - The file is the same format the command line reads with
-cand writes withobfy config generate, and the Visual Studio extension readsobfy.jsonfrom the project folder. Nothing loads it by itself. The CLI needs-c.
Obfuscate stays disabled, with the reason shown, while the settings are invalid: a watermark with no id, signing with no key file or a key file that is missing, a .pfx or .p12 key with no password variable, or an unknown packing target.
Techniques
On Protection, the list groups every technique: Names, Data, Code, Runtime checks, Packaging, Housekeeping and Scope. Each row has a switch. Select a row to read what it does, what it costs and what each option means. Use Find an option to search. A row marked Windows only works only on Windows. A row that is unavailable for your target runtime says why.
| Technique | What it does | On in | Watch for |
|---|---|---|---|
| Symbol renaming | Replaces the names of types, methods, fields, properties, events, parameters and namespaces. Styles: Unreadable (default), Sequential (a, b, c), Hash, Random. | All levels | Breaks code that looks names up as text. Public names are renamed too, unless you turn on Preserve public API. Entry points, constructors, interface implementations, constants, and public or protected virtual methods of unsealed types are left alone automatically. |
| String encryption | Encrypts string literals and decrypts them as they are used. AES-256 (default) or XOR. Strings shorter than the minimum length (3) are left alone. | Standard, Aggressive | A small run-time cost. |
| Constant encryption | Hides integer, long, float and double constants. XOR (default) or AES-256. Values such as -1, 0 and 1 are skipped by default. | Aggressive | Constants in hot loops are worked out every time. |
| Resource encryption | Encrypts embedded resources. AES-256 (default) or XOR. .resources files are skipped by default. | Aggressive | Only calls to Assembly.GetManifestResourceStream are rewritten. Resources read any other way stay encrypted, and the log warns when no call was rewritten. |
| Control flow | Rewrites each method so its steps no longer read top to bottom. Modes: Switch flattening, Opaque conditions, Combined. Intensity 0 to 100. | Aggressive | Slower in hot loops, larger output, harder stack traces. |
| Reference proxy | Routes calls to your own code through generated helper methods. An option also proxies calls into other libraries, and turns the proxy on. | Aggressive | One extra call per proxied call. |
| Method body encryption | Keeps method bodies encrypted in the file and decrypts them in memory when the assembly loads. | Aggressive | Windows only. Generic methods are left as they are. |
| Virtualization | Translates eligible methods into bytecode for a small interpreter that ships with the output. | No level | Methods with exception handling, generics, by-reference parameters, constructors, switch or typeof are left as they are. Translated methods run slower. A deterrent. |
| Debugger check | Notices an attached debugger. | Aggressive | Your own debugger trips it. Test the protected build with none attached. Off Windows, only its managed checks run. |
| Integrity check | Verifies at the entry point, at module start-up, or both, that the file has not changed since it was protected. | Aggressive | Any change to the file afterwards, such as patching, makes it fail. Test the exact file you ship, including any signing step you run after Obfy. |
| Memory image guard | Wipes the file headers from the running program’s memory and patches the Windows memory-dump function inside your own process. | Aggressive | Windows only, x86 and x64 only. Tools that dump the process from outside are not affected. |
| Decompiler resistance | Adds decoy types and methods, and optionally look-alike attributes that other tools leave behind. | Aggressive | Adds noise, not a barrier. The file grows with every decoy. |
| Merge assemblies | Combines the included assemblies into one file. | No level | Needs two or more assemblies. |
| Embed dependencies | Packs the DLLs your program refers to, found next to the input, into the output as resources named Obfy.Embedded.*. | No level | Only DLLs next to the input that it refers to. |
| Native packing | Replaces the managed file with a small native launcher for Windows x64. Target portable keeps a managed launcher, {name}.launcher.exe, instead. | No level | Needs an input with an entry point, so applications, not libraries. A single library fails with “Packing failed” after the obfuscated file is already written; in a closed set, libraries are left as they are. The result still needs the .NET runtime on the machine. Ship the generated .runtimeconfig.json with it. A packed launcher is not strong-name signed. |
| Strong-name signing | Signs the output with a key file: .snk, .pfx or .p12. | No level | A .pfx or .p12 key needs the name of an environment variable that holds its password. The password is never stored in the settings. |
| Metadata removal | Remove debug information drops debug symbols, local variable names and the debuggable attribute. Remove attributes drops nine compiler and debugger attributes: CompilerGenerated, Nullable, NullableContext, DebuggerNonUserCode, DebuggerStepThrough, DebuggerHidden, DebuggerDisplay, DebuggerBrowsable and SuppressMessage. Remove documentation drops the embedded XML documentation. | Debug information: all. Attributes: Standard, Aggressive. | Without debug information a protected build cannot be debugged line by line, and stack traces carry no file names or line numbers. Your own attributes are kept. |
| Watermark | Stamps an id of your choice into the output as an attribute, so you can tell which customer or build a copy came from. | No level | Anyone who inspects the assembly can read the id. It traces a copy; it does not stop copying. |
| Incremental cache | Skips inputs whose bytes, settings and Obfy version have not changed. Keeps {output}.obfycache. | No level | The log then says “Incremental: reused cached output”. |
| Inclusions and exclusions | Rules that leave names alone, or limit protection to some of them. See the next section. | Not a level |
What can break, and how to leave names alone
Renaming changes names, and some techniques change structure. Code that finds things by name, or depends on a file staying as it was built, can stop working. Protect, then test. Keep the symbol map.
| Your code does this | Why it breaks | What to do |
|---|---|---|
Looks up types or methods by name: Type.GetType("MyApp.Plugin"), GetMethod("Run"), plugin loaders, Activator by name | The names change. | Exclude those types and methods, or mark them [Obfuscation(Exclude = true)]. |
| Serializes with names: System.Text.Json, XmlSerializer, data contracts | Property and type names end up in the data. | A type that carries Serializable, DataContract, DataMember, JsonPropertyName, JsonProperty, XmlElement or XmlAttribute is left alone, and a member that carries one keeps its name. A plain class without them is renamed, so exclude it by type name (*Dto) or add an attribute. The list of attributes is in the configuration file under exclusions.attributes. A list you write there replaces the default one, so include the defaults you still want. |
Finds services by convention: controllers named *Controller, handlers found by suffix, DI registered by scanning | The names change. | Exclude those types (*Controller, *Handler). When the files come from an ASP.NET project, Obfy adds the Route, ApiController, HttpGet, HttpPost, HttpPut and HttpDelete attributes to the exclusions. |
| Uses XAML (WPF, WinForms, MAUI) | Bindings use property names, and XAML names types. | Turn on Preserve XAML bindings. It keeps public instance properties of types that end in View or ViewModel, implement INotifyPropertyChanged, declare dependency properties or derive from a DependencyObject. Framework base classes often cannot be resolved, so name view-models *ViewModel. If it finds no such type, the run warns. It does not keep type names: exclude windows, user controls, converters and custom controls that XAML names. |
Reads resources some way other than GetManifestResourceStream | Encrypted resources stay encrypted. | Turn off resource encryption, or exclude those resources with resourceEncryption.excludePatterns in the configuration file. |
| Is a library other code compiles against | Public names are renamed. | Turn on Preserve public API. |
| Is exposed to COM | Names matter to COM. | Types and members marked [ComVisible(true)] are never renamed. |
| Runs under a debugger | The debugger check fires. | Test the protected build without one attached. |
| Is a Unity, MAUI or other platform app | The platform finds your names. | See the platform notes below. |
Scope rules
Open Inclusions and exclusions at the bottom of the technique list.
- Write one pattern per line.
*matches any characters and?matches one. Matching ignores case. - Namespace patterns match the namespace. Type patterns match the short type name only, so write
OrderServiceor*Dto, notMyApp.Models.OrderService. Method patterns match the method name. MyApp.Api.*matches child namespaces such asMyApp.Api.Foo. It does not matchMyApp.Apiitself, so list both.- A type that matches an exclusion is left alone completely, members included. A name that matches an exclusion is always left alone, even if an inclusion also lists it.
- Inclusions work the other way. When any inclusion is listed, only matching names are protected. A type matches when its namespace or its name matches. If nothing matches, the log says “Inclusions matched 0 types/methods; nothing was obfuscated.”
The [Obfuscation] attribute
You can mark code in your own source with System.Reflection.ObfuscationAttribute.
[Obfuscation(Exclude = true)] // leave this type alone, everywhere
public class License { }
[Obfuscation(Exclude = true, Feature = "renaming")] // keep the name, still encrypt strings
public class Dto { }
Feature can be all (the default), renaming, controlflow, strings, constants or virtualization. On a type, ApplyToMembers is true by default. [Obfuscation(Exclude = true, ApplyToMembers = false)] keeps the type name and still protects its members. A setting on a member wins over the type.
Platform notes
- Unity. Obfuscate the managed player assemblies, not the native output, and do it before IL2CPP runs. For an IL2CPP player, choose the Unity IL2CPP runtime. Exclude
UnityEngine,UnityEngine.*,UnityandUnity.*: the.*form does not match the namespace itself, so list both. - MAUI. Turn on Preserve XAML bindings and exclude
Microsoft.MauiandMicrosoft.Maui.*. - NativeAOT. Obfuscate before
dotnet publish.
Results
Before a run, Results says there is nothing to show. During a run it shows progress. Press Esc or Cancel to stop. Files that finished stay in the output folder. A cancelled run, or one that stops on an unexpected error, clears the results.
After a run, the header shows the number of files, how many failed and the time. Open output folder opens the folder the output went to. Export report... saves an HTML report, or JSON if the name ends in .json. Export symbol map... saves the map as JSON.
| Tab | What it shows |
|---|---|
| Summary | Counts of what was renamed, encrypted, protected and removed (zero counters are hidden), and each output file with a Reveal link. A failed file shows why. |
| Symbols | The symbol map as a tree: the original name, then the new one. Members sit under their type. Search by original or new name. The tree loads 200 rows at a time; choose Show more for the rest. |
| Preview | The decompiled C# of one output assembly, as a reader would see it. Nothing is decompiled until you choose an assembly. Long output is cut at 24,000 characters. It works for assemblies, not for source output. |
| Log | Every line of every run since the log was last cleared, with a separator between runs. Problems only shows warnings and errors. Timestamps, Wrap, Copy and Clear are on the toolbar. Copy copies the lines you can see. |
Results belong to the last run. The next run replaces them, and closing the app discards them. If you need the map later, write it to a file (see Reading a stack trace).
Reading a stack trace with the symbol map
A stack trace from a protected build shows the new names. The symbol map is how you get the originals back. Obfy has no retrace command, so the map is a JSON file you search.
- Keep a map for every build you ship. Turn on Write a symbol map on Files before the run. It is off by default. Or choose Export symbol map... on Results right after the run. From the command line, use
--map symbols.json. The Visual Studio extension writes one only when Generate Symbol Map is on. - Store it with the build it belongs to, and keep it private. The Unreadable, Random and Hash styles give different names on every build. Sequential names depend on the order Obfy processes the code. A map from one build does not read another build’s traces.
- Look up each name from the trace in the map’s values. Keys start with the kind:
Namespace:,Type:,Method:,Field:,Property:orEvent:. Method keys include the signature. Within one run each new name is used once, so a name matches one entry.
{
"Namespace:MyApp.Orders": "a",
"Type:MyApp.Orders.OrderService": "b",
"Method:MyApp.Orders.OrderService.CalculateTotal(System.Decimal ())": "c"
}
A trace line at a.b.c() reads as namespace a, type b, method c, which is MyApp.Orders.OrderService.CalculateTotal. A property accessor in a trace is get_ or set_ plus the new property name, and an event accessor is add_ or remove_ plus the new event name.
In the app, the Symbols tab does this lookup for the last run: search for the new name. For a saved file, this PowerShell finds the key for a name:
$map = Get-Content symbolmap.json -Raw | ConvertFrom-Json
$map.PSObject.Properties | Where-Object { $_.Value -eq 'c' } | ForEach-Object { $_.Name }
Things that catch people out:
- Default names do not survive a text search. Unreadable names use zero-width and look-alike characters, and the file stores them as
\uXXXXescapes. A name copied from a trace will not match in a plain text search of the file. Use a JSON-aware lookup such as the PowerShell above, or choose Sequential naming for builds whose traces you expect to read. - No file names or line numbers. Debug information is removed at every level, so traces show method names only.
- A cancelled run writes no map. Files that finished are in the output folder, but there is no map for them. Run again.
- Control flow makes traces harder to follow, even with the map.
Keyboard shortcuts
| Keys | Action | Notes |
|---|---|---|
| Ctrl+O | Add files | Opens the picker. Refused during a run. |
| Ctrl+S | Save configuration | Saves to the file you opened or last saved. Asks where the first time. |
| Ctrl+L | Open configuration | Opens the picker. Refused during a run. |
| Ctrl+Enter | Obfuscate | Does nothing during a run, or while the run bar says it cannot start. |
| Esc | Cancel the run | Only during a run. Also closes an open row menu. |
| F1 | Open the Guide | |
| Delete | Remove the selected files | Click a row first. Not during a run. |
These work wherever the window has focus, except Delete, which needs a row in the file list. Ctrl+C copies selected text, as in any page. To copy log lines, select them or use Copy on the Log tab.
Command line
obfy <input>... [options]
obfy config generate [-o <file>] [-l <level>]
obfy config wizard [-o <file>] [-q]
obfy --help lists everything. The options below are the ones in the current build.
Which systems. The command line needs .NET 10. Its tests run on Windows and on Linux in CI. macOS is not tested. Method body encryption, the memory image guard and native packing only work in a program that runs on Windows, and native packing writes a Windows x64 launcher.
Options
| Option | What it does |
|---|---|
<input>... | One or more of .dll, .exe, .cs, .sln, .slnx, .csproj, .vbproj, .fsproj. |
-o, --output <dir> | Output directory. |
-l, --level <level> | minimal, standard, aggressive or custom. Default standard. |
-c, --config <file> | Read settings from a configuration file. |
--merge | Merge all input assemblies into one before protecting. |
--internalize | With --merge, make merged types internal. On by default. --internalize false keeps them public. |
--rename, --no-symbol-renaming | Turn symbol renaming on or off. |
--preserve-public | Keep public API names. |
--string-encrypt, --no-string-encryption | Turn string encryption on or off. |
--encrypt-constants | Turn constant encryption on. |
--encrypt-resources | Turn resource encryption on. |
--control-flow, --no-control-flow | Turn control flow on or off. |
--reference-proxy | Turn the reference proxy on. |
--proxy-external | Also proxy calls into other libraries. Turns the reference proxy on. |
--encrypt-methods | Turn method body encryption on. |
--virtualize | Turn virtualization on. |
--anti-debug | Turn the debugger check on. |
--anti-tamper | Turn the integrity check on. |
--anti-dump | Turn the memory image guard on. |
--anti-decompiler | Turn decompiler resistance on. |
--strip-metadata | Remove debug information. |
--watermark-id <id> | Turn the watermark on and set its id. A blank id is an error. |
--incremental | Skip inputs that have not changed. |
--map <file> | Write the symbol map. |
--report <file> | Write a report: JSON if the name ends in .json, HTML otherwise. |
--dry-run | Analyze only. Write nothing. |
-v, --verbose | More output. |
--no-logo | Hide the banner. |
--version, -h, --help | Version, help. |
How the options combine
- Without
-c, the level sets the starting point. Any protection flag is applied on top, and the run uses the result as Custom. - With
-c, the file is used as it is.--levelis ignored, with a message. Protection flags still apply on top. - Packing, signing, the target runtime, embed dependencies, inclusions and exclusions, algorithms, the control flow mode and intensity, the naming style and Preserve XAML are only in the configuration file. There is no
--packflag.--watermark-id,--virtualizeand--incrementalturn those features on, and everything else about them stays in the file.
| In the app | On the command line |
|---|---|
| Level | -l |
| Write a symbol map | --map <file> |
| Merge assemblies, Make merged types internal | --merge, --internalize false |
| Native packing, signing, target runtime, embed dependencies | packing, signing, runtimeProfile, dependencyEmbedding in the configuration file |
| Inclusions and exclusions | inclusions, exclusions in the configuration file |
Where the output goes
| Input | Without -o | With -o dir |
|---|---|---|
One assembly or .cs file | Name.obfuscated.ext next to the input | dir/Name.ext |
| Two or more assemblies | obfy-out next to the first assembly | dir |
| A solution or project (extra assemblies may follow) | obfy-out next to the solution or project file | dir |
Two or more .cs files | obfy-src next to the first file | dir |
--merge | First.merged.dll next to the first assembly | dir/First.dll |
Two differences from the desktop app: a merge is named .merged here and .obfuscated in the app, and for a solution the app puts obfy-out next to the first included assembly rather than the solution.
Rules for several inputs
- A solution or project, or two or more assemblies, is a closed set.
--mergemerges instead. Extra.dlland.exearguments join a solution’s set. - Two solution files in one run is an error.
--mergeneeds at least two assemblies. With a solution that has fewer than two, it warns and continues as a closed set.- Source files are skipped in a closed set, with a warning. Two or more
.csfiles alone are compiled together. - A named file that does not exist fails the run.
- PowerShell does not expand
*.dll. UseGet-ChildItem, or run fromcmd.exe.
Exit codes
| Code | Meaning |
|---|---|
| 0 | Success, including a dry run. |
| 1 | An error: a missing file, a failed run, two solution files, an assembly that failed to load, an invalid option. |
| 2 | A solution, project or set of loose assemblies had nothing to protect. |
Examples
# One file, Standard
obfy MyApp.dll -o output/
# A solution as a closed set, preview first
obfy MyApp.sln --dry-run
obfy MyApp.sln -o out/
# Aggressive, with a symbol map and a report
obfy MyApp.dll -l aggressive -o output/ --map symbols.json --report report.html
# Pick protections yourself, on top of Standard
obfy MyApp.dll --encrypt-constants --control-flow -o output/
# Make a configuration, edit it, then use it
obfy config generate -l aggressive -o obfy.json
obfy MyApp.dll -c obfy.json -o output/
# Merge two assemblies
obfy App.dll Lib.dll --merge -o output/
obfy config wizard asks questions and writes a configuration file. It needs an interactive terminal. --quick only asks for the application type and the level.
Visual Studio and build systems
The Visual Studio extension runs the obfy command, so it must be installed. It looks for obfy.exe in Program Files\Obfy, then your PATH, then .dotnet\tools in your user folder. If it is not found, the output says “Obfy CLI not found”. It keeps per-project settings in obfy.json in the project folder, and passes it to the CLI with -c when it exists. With no file, it passes the level it shows.
The extension replaces the project’s build output in place with the protected file. It does not write to a separate folder.
Visual Studio 2022. Right-click a project in Solution Explorer for Obfuscate, Enable Post-Build Obfuscation and Obfy Settings.... Tools > Options > Obfy > General sets the defaults: Default Level (Standard), Enable Post-Build by Default (off), Release Only (on), Generate Symbol Map (off) and Show Output Window (on). When Generate Symbol Map is on, the map is written beside the output assembly as {name}.map.json. Post-build obfuscation runs after a successful build of a project that has it enabled, and by default only for Release.
The extension is built from source. It is not on the Visual Studio Marketplace, and no GitHub release carries it. You build it and install the VSIX. The repository README has the steps.
MSBuild. This target protects the Release output in place after each build:
<Target Name="Obfuscate" AfterTargets="Build" Condition="'$(Configuration)' == 'Release'">
<Exec Command="obfy "$(TargetPath)" -c obfy.json -o "$(TargetDir)"" />
</Target>
CI. Install the tool, then call obfy:
- uses: actions/setup-dotnet@v4
with:
dotnet-version: '10.x'
- run: |
dotnet tool install --global Obfy
obfy bin/Release/net10.0/MyApp.dll -c obfy.json -o dist/
Protect the build output first, and publish afterwards. For a single-file publish, give Obfy the assemblies from the build, not the single-file executable.
Troubleshooting and FAQ
Desktop app
- Obfuscate is greyed out.
- The run bar says why. The reasons are: no included file (“Add at least one included file.”); a watermark with no id; signing with no key file, a key file that is not found, or a
.pfxor.p12key with no password variable; an unknown packing target; or a run already going. - Dropping a file does nothing.
- A file of a type Obfy does not accept is ignored without a message. During a run, a drop is refused with a “Run in progress” notice. Any existing
.jsonfile you drop loads as a configuration. - “Nothing to protect. No built outputs found.”
- A solution or project had no built assemblies. Build Release, choose Clear, and add it again. Skipped project rows cannot be included by hand.
- “Several configurations dropped.”
- Only the first
.jsonloads. The notice names the one that was used. - “Saved output directory was not found.”
- The remembered output folder is gone. The box is cleared. Choose a folder or leave it empty.
- “Source files are not part of a closed-set session.”
- A
.csfile was included with assemblies in a closed set. It is skipped. Run it on its own. - “Closed-set obfuscation stopped because N assembly(ies) failed to load.”
- Nothing was written. The log names the files and the cause.
- “Packing failed: Packing requires an assembly with an entry point.”
- Native packing is on and the input is a library. Turn packing off for libraries. The obfuscated file was already written.
- The log says “Incremental: reused cached output” and Results show no changes.
- The incremental cache found nothing new. Delete the
.obfycachefile next to the output, or change a setting. - A warning says preserveXaml found no ViewModel or View types.
- Name view-models
*ViewModelor*View, or exclude the types by name. See What can break. - The log says “N item(s) in X were skipped and left unobfuscated.”
- Those items could not be protected. Use Problems only on the Log tab to read the reasons.
- The protected app crashes or behaves differently.
- Run the same input at Minimal. If that works, raise the level one step at a time. Then see What can break. The usual causes are names used as text, a debugger attached, a Windows-only protection on another system, and native packing on a machine without the .NET runtime.
- The window shows “The web view that draws Obfy’s interface did not start”.
- Choose Restart Obfy. If it comes back, choose Open log folder. The Microsoft Edge WebView2 Runtime may need repairing.
- Where are the logs?
%LOCALAPPDATA%\Obfy\Logs\. Preferences are in%APPDATA%\Obfy\ui-preferences.json.
Command line
| Message or symptom | Meaning |
|---|---|
--level is ignored because --config was given. | The file decides the options. Use obfy config generate -l ... to make a file for a level. |
Only one solution file can be obfuscated per run. | Pass one .sln or .slnx. |
Merge requires at least two input assemblies. | --merge needs two or more assemblies. |
config wizard needs an interactive terminal. | Run it in a terminal, not a pipe or a build step. |
Config file not found | Check the path given to -c. |
| Exit code 2 | Nothing to protect. Build the project, or check the paths. |
FAQ
- Can I get my code back from the output?
- The output is still readable to a determined person. The symbol map gives you the original names, nothing more. Keep it private.
- Is it safe to hide a secret in a string?
- No. See the note at the top of this guide.
- Which level should a library use?
- Standard, with Preserve public API on, so callers still compile against your public names.
- Do the app and the command line share settings?
- They share the configuration file format. The output folder and symbol map choice in the app are app preferences and are not in the file.
- Does Obfy change my original files?
- The app and the CLI do not, unless you choose the input’s own folder as the output. The Visual Studio extension does replace the build output.
- Does it run on Linux or macOS?
- The desktop app is Windows only. The command line needs .NET 10 and is tested on Windows and on Linux. It is not tested on macOS, so nothing here says it works there. Method body encryption, Memory image guard and Native packing are Windows features: the protected program has to run on Windows.