开发者

How to configure babel.net obfuscator to only run on release builds?

I was able to modify *.proj file for the project to include babel build target.

<Import Project="C:\Program Files\Babel\MSBuild\Babel.Build.targets" />

This works but executes babel for both debug and release builds. I want babel to obfuscate only release builds. Per pg 82 of the manual I should include the following code.

<Import Project="C:\Program Files\Babel\MSBuild\Babel.Build.targets" />
<Choose>
<When Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PropertyGroup>
<EnableObfuscation>false</EnableObfusca开发者_JS百科tion>
</PropertyGroup>
</When>
<When Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PropertyGroup>
<EnableObfuscation>true</EnableObfuscation>
<ILIterations>3</ILIterations>
<StringEncryption>true</StringEncryption>
</PropertyGroup>
</When>
</Choose>

However when including this code in the *.proj file I get build error that "EnableObfuscation" is not a valid option.


Check your path to the Babel.Build.targets is correct. Then edit that file and search for the EnableObfuscation property to make sure it exists.

I altered the suggested config from the documentation to the following and added to all my projects and it works fine.

<Import Project="C:\Program Files\Babel\MSBuild\Babel.Build.targets" />
  <Choose>
    <When Condition=" '$(Configuration)' == 'Debug' ">
      <PropertyGroup>
        <EnableObfuscation>false</EnableObfuscation>
      </PropertyGroup>
    </When>
    <When Condition=" '$(Configuration)' == 'Release' ">
      <PropertyGroup>
        <EnableObfuscation>true</EnableObfuscation>
        <ILIterations>3</ILIterations>
        <StringEncryption>true</StringEncryption>
      </PropertyGroup>
    </When>
  </Choose>

The above works in my Windows Phone 7 project and works with the XAP file by adding this in addition to the startup project

  <Target Name="AfterBuild">
    <CreateProperty Value="@(_OutputPathItem->'%(FullPath)$(XapFilename)')">
      <Output TaskParameter="Value" PropertyName="BabelInputFile"/>
    </CreateProperty>
  </Target>


I was using the NuGet package and ended up using a condition for the packageReference in my csproject:

<ItemGroup Condition="'$(Configuration)'=='Release'">
  <PackageReference Include="Babel.Obfuscator" Version="X.X.X">
    <PrivateAssets>all</PrivateAssets>
    <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
 </PackageReference>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜