Last active
January 3, 2022 06:09
-
-
Save maxkatz6/a74cda4ef5c58591d9393891ac0a60a5 to your computer and use it in GitHub Desktop.
obfuscar.xml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<Project Sdk="Microsoft.NET.Sdk"> | |
<!-- ... --> | |
<Import Project="../Obfuscar.targets" /> | |
<!-- ... --> | |
</Project> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<Project> | |
<PropertyGroup> | |
<EnabledRunObfuscar Condition="'$(PublishProtocol)'!=''">true</EnabledRunObfuscar> | |
</PropertyGroup> | |
<!-- To support single file, Obfuscar should run on obj/ folder binaries after compilation and not after actual publish --> | |
<!-- Also we need to copy compiled dependeincies for obfuscar as well --> | |
<Target Name="RunObfuscar" BeforeTargets="CopyFilesToOutputDirectory" Condition="'$(EnabledRunObfuscar)'=='true'"> | |
<PropertyGroup> | |
<ProjectBuildOutput>$(OutputPath)</ProjectBuildOutput> | |
<ObfuscarRootPath>$(IntermediateOutputPath)</ObfuscarRootPath> | |
<ObfuscarRootAssembliesPath>$([System.IO.Path]::Combine($(ObfuscarRootPath),"bin-copy"))</ObfuscarRootAssembliesPath> | |
<ObfuscarToolPath>$([System.IO.Path]::Combine($(MSBuildThisFileDirectory),"Tools"))</ObfuscarToolPath> | |
<ObfuscarToolFileName>$([System.IO.Path]::Combine($(ObfuscarToolPath),"obfuscar.console"))</ObfuscarToolFileName> | |
<ObfuscarXmlFileName>obfuscar.xml</ObfuscarXmlFileName> | |
<ObfuscarXmlPath>$([System.IO.Path]::Combine($(MSBuildThisFileDirectory),"Builds",$(ObfuscarXmlFileName)))</ObfuscarXmlPath> | |
<ObfuscarOutput>$(ObfuscarRootPath)/Obfuscated</ObfuscarOutput> | |
</PropertyGroup> | |
<Message Importance="high" Text="Install Obfuscar" /> | |
<Exec Command="dotnet tool install Obfuscar.GlobalTool --version 2.2.32 --tool-path "$(ObfuscarToolPath)"" ContinueOnError="true" /> | |
<Message Importance="high" Text="Copy built assemblies" /> | |
<ItemGroup> | |
<_BuildAssemblies Include="$(ProjectBuildOutput)/**/*.dll" Exclude="$(ProjectBuildOutput)/MyAssembly.dll" /> | |
</ItemGroup> | |
<Copy SourceFiles="@(_BuildAssemblies)" DestinationFolder="$(ObfuscarRootAssembliesPath)" /> | |
<Message Importance="high" Text="Run Obfuscar with config from $(ObfuscarXmlPath) in directory $(ObfuscarRootPath)" /> | |
<Exec Command=""$(ObfuscarToolFileName)" "$(ObfuscarXmlPath)" -s" WorkingDirectory="$(ObfuscarRootPath)" /> | |
<ItemGroup> | |
<_ObfuscatedFiles Include="$(ObfuscarOutput)/*" Exclude="$(ObfuscarOutput)/Mapping.txt" /> | |
</ItemGroup> | |
<Message Importance="high" Text="Copy obfuscated files: @(_ObfuscatedFiles->'%(Filename)%(Extension)', ' ')" /> | |
<Copy SourceFiles="@(_ObfuscatedFiles)" DestinationFolder="$(ObfuscarRootPath)" /> | |
<ItemGroup> | |
<_FilesToDelete Include="$(ObfuscarRootAssembliesPath)/*" /> | |
</ItemGroup> | |
<Message Importance="high" Text="Cleanup after obfuscation: @(_FilesToDelete->'%(Filename)%(Extension)', ' ')"/> | |
<Delete Files="@(_FilesToDelete)" /> | |
<RemoveDir Directories="$(ObfuscarOutput)" /> | |
</Target> | |
</Project> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version='1.0'?> | |
<Obfuscator> | |
<Var name="InPath" value="." /> | |
<Var name="OutPath" value="$(InPath)/Obfuscated" /> | |
<Var name="KeepPublicApi" value="true" /> | |
<Var name="HidePrivateApi" value="true" /> | |
<AssemblySearchPath path=".\bin-copy" /> | |
<Module file="$(InPath)/MyAssembly.dll"> | |
<SkipType name="!AvaloniaResources" /> | |
<SkipType name="CompiledAvaloniaXaml*" /> | |
<SkipNamespace name="CompiledAvaloniaXaml*" /> | |
<SkipField type="*" rx="\$*" /> | |
</Module> | |
</Obfuscator> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment