Skip to content

Instantly share code, notes, and snippets.

@amenayach
Created May 14, 2021 20:02
Show Gist options
  • Save amenayach/7ae585e0ba2e554c62ba23bbedc4c614 to your computer and use it in GitHub Desktop.
Save amenayach/7ae585e0ba2e554c62ba23bbedc4c614 to your computer and use it in GitHub Desktop.
Obfuscar sample config tested on dotnet core 2.2
<YouProject>.csproj
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp2.2</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Obfuscar" Version="2.2.30">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>
<ItemGroup>
<None Update="obfuscar.xml">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
<Exec Command="$(Obfuscar) obfuscar.xml" />
</Target>
</Project>
// add obfuscar.xml on project root
<?xml version="1.0" encoding="utf-8" ?>
<Obfuscator>
<Var name="InPath" value=".\bin\Debug\netcoreapp2.2" />
<Var name="OutPath" value="$(InPath)\obfuscatedrelease" />
<Var name="KeepPublicApi" value="false" />
<Var name="HidePrivateApi" value="true" />
<Var name="RenameProperties" value="true" />
<Var name="RenameEvents" value="true" />
<Var name="RenameFields" value="true" />
<Var name="UseUnicodeNames" value="true" />
<Var name="HideStrings" value="true" />
<Var name="OptimizeMethods" value="true" />
<Var name="SuppressIldasm" value="true" />
<Module file="$(InPath)\<YouProject>.dll" />
</Obfuscator>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment