如何配置 babel.net obfuscator 仅在发布版本上运行?
我能够修改项目的 *.proj 文件以包含 babel 构建目标。
<Import Project="C:\Program Files\Babel\MSBuild\Babel.Build.targets" />
这可以工作,但会为调试和发布版本执行 babel。我希望 babel 仅混淆发布版本。根据手册第 82 页,我应该包含以下代码。
<Import Project="C:\Program Files\Babel\MSBuild\Babel.Build.targets" />
<Choose>
<When Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PropertyGroup>
<EnableObfuscation>false</EnableObfuscation>
</PropertyGroup>
</When>
<When Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PropertyGroup>
<EnableObfuscation>true</EnableObfuscation>
<ILIterations>3</ILIterations>
<StringEncryption>true</StringEncryption>
</PropertyGroup>
</When>
</Choose>
但是,当将此代码包含在 *.proj 文件中时,我收到构建错误,指出“EnableObfuscation”不是有效选项。
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</EnableObfuscation>
</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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
检查 Babel.Build.targets 的路径是否正确。然后编辑该文件并搜索 EnableObfuscation 属性以确保它存在。
我将建议的配置从文档更改为以下内容,并将其添加到我的所有项目中,并且工作正常。
上面的内容适用于我的 Windows Phone 7 项目,并通过将其添加到启动项目中来使用 XAP 文件
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.
The above works in my Windows Phone 7 project and works with the XAP file by adding this in addition to the startup project
我正在使用 NuGet 包,最终在我的 csproject 中使用了 packageReference 的条件:
I was using the NuGet package and ended up using a condition for the packageReference in my csproject: