How do I use Obfuscar with a project that builds for multiple frameworks?

28 views Asked by At

I have a project that creates a NuGet package that supports multiple frameworks. When the project is compiled it creates separate folders in the Release folder for each framework.

i.e., Release\net6.0, Release\net48, Release\net472

I am trying to figure out what to put into the obfuscar.xml file so that the files in each of the subfolders are run through Obfuscar and then saved into separate output folders.

i.e., Obfuscated\net6.0, Obfuscated\net48, Obfuscated\net472

What I have currently tried is this, but it is saving the output in the project folder without keeping the different framework versions separate.

<?xml version='1.0'?>
<Obfuscator>
  <Var name="TargetFrameworksPath1" value="net6.0" />
  <Var name="TargetFrameworksPath2" value="net472" />
  <Var name="TargetFrameworksPath3" value="net48" />

  <Var name="InPath1" value=".\Project\bin\Release\$(TargetFrameworksPath1)"/>
  <Module file="$(InPath1)\Project.dll">
    <Var name="OutPath" value=".\Project\bin\Obfuscator_Output\$(TargetFrameworksPath1)"/>
  </Module>

  <Var name="InPath2" value=".\Project\bin\Release\$(TargetFrameworksPath2)"/>  
  <Module file="$(InPath2)\Project.dll">
    <Var name="OutPath" value=".\Project\bin\Obfuscator_Output\$(TargetFrameworksPath2)"/>
  </Module>

  <Var name="InPath3" value=".\Project\bin\Release\$(TargetFrameworksPath3)"/>
  <Module file="$(InPath3)\Project.dll">
    <Var name="OutPath" value=".\Project\bin\Obfuscator_Output\$(TargetFrameworksPath3)"/>
  </Module>

  <Var name="HidePrivateApi" value="true"/>
</Obfuscator>
0

There are 0 answers