本篇文章主要介绍如何将Dotfuscator集成到Visual Studio项目中。
Dotfuscator是一款.NET混淆器和压缩器,防止你的应用程序被反编译。
【下载Dotfuscator最新试用版】
保护你的应用
保护整个应用程序就像在应用程序的Visual Studio项目文件中添加几行代码一样简单(例如,MyExecutable.csproj)。集成后,Dotfuscator Professional将自动保护您的所有程序集 – 无论是来自应用程序的项目还是解决方案中的其他项目。 每次的版本发布也会自动保护。
本次《Dotfuscator教程:保护你的应用》包括以下内容:
- 集成到Visual Studio项目中
- 检查受保护的程序集
- 存档 告文件
- 加强保护
- 替代方法
本篇文章主要介绍如何将Dotfuscator集成到Visual Studio项目中。
集成到Visual Studio项目中
.NET Framework
要保护.NET Framework项目,请复制下面显示的新XML元素(PropertyGroup等),并在结束标签/Project之前将它们粘贴到项目文件中。请注意,元素的顺序很重要。
<ml version="1.0" encoding="utf-8"gt;<Project ToolsVersion="15.0" DefaultTargets="Build"> <!-- ...existing tags... --> <!-- Set build properties for Dotfuscator --> <PropertyGroup> <!-- Generate a default Dotfuscator config file (DotfuscatorConfig.xml) --> <!-- TODO: Set this to false after the file is generated by the first local build --> <DotfuscatorGenerateConfigFileIfMissing>true</DotfuscatorGenerateConfigFileIfMissing> <!-- Enable Dotfuscator for Release builds --> <DotfuscatorEnabled Condition="'$(Configuration)' == 'Release'">true</DotfuscatorEnabled> </PropertyGroup> <!-- Import the Dotfuscator MSBuild targets last --> <Import Project="$(MSBuildExtensionsPath)PreEmptiveDotfuscator4PreEmptive.Dotfuscator.Common.targets"/></Project>
.NET Core or .NET Standard
要保护.NET Core或.NET Standard项目,请首先从项目的根Project标记中删除Sdk属性。然后,将下面显示的新元素复制到项目文件中的相应位置。
<Project><!-- ORIGINALLY WAS: <Project Sdk="Microsoft.NET.Sdk"> The Sdk attribute has been replaced with explicit <Import> tags to ensure Dotfuscator's targets are imported after "Sdk.targets" --> <!-- Import SDK properties --> <!-- (before any existing tags) --> <Import Project="Sdk.props" Sdk="Microsoft.NET.Sdk" /> <!-- ...existing tags... --> <!-- Import SDK targets --> <!-- (after any existing tags but before Dotfuscator targets) --> <Import Project="Sdk.targets" Sdk="Microsoft.NET.Sdk" /> <!-- Set build properties for Dotfuscator --> <PropertyGroup> <!-- Generate a default Dotfuscator config file (DotfuscatorConfig.xml) --> <!-- TODO: Set this to false after the file is generated by the first local build --> <DotfuscatorGenerateConfigFileIfMissing>true</DotfuscatorGenerateConfigFileIfMissing> <!-- Enable Dotfuscator for Release builds --> <DotfuscatorEnabled Condition="'$(Configuration)' == 'Release'">true</DotfuscatorEnabled> </PropertyGroup> <!-- Import the Dotfuscator MSBuild targets last --> <Import Project="$(MSBuildExtensionsPath)PreEmptiveDotfuscator4PreEmptive.Dotfuscator.Common.targets"/></Project>
Xamarin
Dotfuscator与Xamarin应用程序集成是Xamarin构建过程的一部分,可使用与其他.NET平台相同的方法。但是,在开始之前,你应该了解Xamarin集成的一些特别的方面。
要保护你的Xamarin应用程序,你必须将Dotfuscator集成到每个输出项目(Android,iOS和UWP)中。Dotfuscator将保护项目输出目录中源自项目解决方案的所有程序集。为了保护Xamarin项目(我们建议从Android开始),请在结束标签/Project之前将下面显示的新元素复制到项目文件中的相应位置。
<ml version="1.0" encoding="utf-8"gt;<Project ToolsVersion="4.0" DefaultTargets="Build" > <!-- ...existing tags... --> <!-- Set build properties for Dotfuscator --> <PropertyGroup> <!-- Generate a default Dotfuscator config file (DotfuscatorConfig.xml) --> <!-- TODO: Set this to false after the file is generated by the first local build --> <DotfuscatorGenerateConfigFileIfMissing>true</DotfuscatorGenerateConfigFileIfMissing> <!-- Enable Dotfuscator for Release --> <DotfuscatorEnabled Condition="'$(Configuration)' == 'Release'">true</DotfuscatorEnabled> <!-- Enable Dotfuscator for Ad-Hoc (only needed for iOS) --> <DotfuscatorEnabled Condition="'$(Configuration)' == 'Ad-Hoc'">true</DotfuscatorEnabled> <!-- Enable Dotfuscator for AppStore (only needed for iOS) --> <DotfuscatorEnabled Condition="'$(Configuration)' == 'AppStore'">true</DotfuscatorEnabled> <!-- Only needed when using Tamper Checks for Android --> <!-- TODO: If using Tamper Checks for Android, set this to the SHA-1 fingerprint of the certificate used to sign the app --> <DotfuscatorAndroidSigningCertFingerprint></DotfuscatorAndroidSigningCertFingerprint> </PropertyGroup> <!-- Import the Dotfuscator MSBuild targets last --> <Import Project="$(MSBuildExtensionsPath)PreEmptiveDotfuscator4PreEmptive.Dotfuscator.Common.targets"/></Project>
Unity
将Dotfuscator集成到Unity项目中需要特殊配置,本次教程不包含这些配置。后续会整理的。
建立项目
在Visual Studio中,将更改保存到项目文件,关闭选项卡,然后重新加载项目。要获得受保护的应用程序,请按照正常情况在发布配置中构建项目。

作为初始构建的一部分,Dotfuscator将生成一个配置文件,DotfuscatorConfig.xml,它具有默认保护设置。构建将发出警告(见上面的屏幕截图),在第一次构建中你可以忽略。将生成的文件加入版本控制。
然后,构建将调用Dotfuscator来保护项目输出目录中的解决方案程序集(.exe和.dll文件)(例如,binRelease)。Dotfuscator还将在新的DotfuscatorReports目录中生成 告文件;你应该从版本控制中排除此目录。
一旦构建完成,您的应用程序现在就受Dotfuscator保护了。注意:有关诊断构建或运行时问题的帮助,请参阅疑难解答。
禁用配置文件生成
在第一次构建期间,Dotfuscator生成了一个具有默认保护设置的配置文件DotfuscatorConfig.xml。此功能在设置时很有用,但是一旦文件存在(并由版本控制跟踪),你应该禁用此功能,因为它可以屏蔽某种构建错误。
将
<!-- Generate a default Dotfuscator config file (DotfuscatorConfig.xml) --> <!-- TODO: Set this to false after this file is generated by the first local build --> <DotfuscatorGenerateConfigFileIfMissing>true</DotfuscatorGenerateConfigFileIfMissing>
替换为
<!-- Error if the Dotfuscator config file (DotfuscatorConfig.xml) is missing --> <DotfuscatorGenerateConfigFileIfMissing>false</DotfuscatorGenerateConfigFileIfMissing>
想要购买正版授权,或者获取更多Dotfuscator相关信息的朋友可以点击” 咨询在线客服 “~
标签:代码保护软件安全代码混淆
声明:本站部分文章及图片源自用户投稿,如本站任何资料有侵权请您尽早请联系jinwei@zod.com.cn进行处理,非常感谢!