Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Usage of Fody/Costura and Obfuscar in Visual Studio 2017

I would like to ask if it is possible to use Fody-Costura, which embeds dependencies into the executable and Obfuscar, for obfuscation, together.

At the moment I’m struggling because the msbuild target in Visual Studio 2017 of Costura gets executed before the one of obfuscar (which then complains about missing dependency files).

As obfuscar does not provide a target by itself, I'm using MSBuild.Obfuscar.

Is there a way to combine those two, maybe by specifying the order of the targets?

like image 744
TheGuy Avatar asked Feb 18 '18 15:02

TheGuy


1 Answers

I made a quick Framework console app project, and I added Costura, MSBuild.Obfuscar, and NLog. In order to get Obfuscar to work, all I had to do was edit the Obfuscar.xml file to include the actual assembly name:

<?xml version="1.0" encoding="utf-8"?>
<Obfuscator>
  <Var name="InPath" value="bin\Release" />
  <Var name="OutPath" value="$(InPath)\obfuscated" />
  <Var name="HidePrivateApi" value="true" />
  <!-- was: file="$(InPath)\"  -->
  <Module file="$(InPath)\ConsoleApp1.exe" />
</Obfuscator>

This built for me just fine. The resulting assembly had my code obfuscated and also included NLog as a resource. If you're seeing different results, then maybe it has to do with the specific other NuGet packages your solution includes.

like image 121
asherber Avatar answered Nov 13 '22 11:11

asherber