在 Visual Studio 中使用 Post-Build 命令进行混淆自动化
Obfuscation Automation by Using Post-Build Commands in Visual Studio
我正在尝试通过在 Visual Studio 2015 年使用 post-build 命令来自动混淆。我已按照 this MSDN 文章中的步骤进行操作。
我添加了步骤中提到的 post-build 命令并创建了 Dotfuscator.xml,放置在根目录中,即 vbproj 文件所在的位置。
构建项目后,我收到以下错误消息。
这里是 post-build 命令:
"C:\Program Files (x86)\Microsoft Visual Studio 14.0\PreEmptive Solutions\Dotfuscator and Analytics Community Edition\dotfuscator.exe" /q /p=SourceDirectory=$(TargetDir),SourceFile=$(TargetFileName) $(ProjectDir)Dotfuscator.xml
任何提示或解决方案将不胜感激。
您需要引用您经过的那些路径...
"C:\Program Files (x86)\Microsoft Visual Studio 14.0\PreEmptive Solutions\Dotfuscator and Analytics Community Edition\dotfuscator.exe" /q /p=SourceDirectory="$(TargetDir)",SourceFile="$(TargetFileName)" $(ProjectDir)Dotfuscator.xml
或者也许
"C:\Program Files (x86)\Microsoft Visual Studio 14.0\PreEmptive Solutions\Dotfuscator and Analytics Community Edition\dotfuscator.exe" /q /p="SourceDirectory=$(TargetDir),SourceFile=$(TargetFileName)" $(ProjectDir)Dotfuscator.xml
通过 运行 命令提示符下的 exe 对其进行测试,以查看它如何处理该参数。
现在您已经解决了 Trevor 描述的引用问题,我认为下一个问题是您可能 运行 一个没有 command-line 支持的 Dotfuscator 版本.
Visual Studio 2015 Update 3(和 VS 2017)包括具有 command-line 支持的 Dotfuscator Community Edition (CE) 版本。 (您必须注册才能启用它。)如果您使用的是早期版本的 VS 2015,您可以从 PreEmptive 下载具有 command-line 支持的 Dotfuscator CE 版本;有关详细信息,请参阅 instructions here。
完全披露:我为 PreEmptive Solutions 工作。
在@Trevor 和@Nathan 的回答的帮助下,我在这里能够实现我想要的。
首先,我使用 Dotfuscator.exe 创建了 Dotfuscator.xml 文件。提供输入文件并生成一次混淆 DLL。
确认 XML 文件工作正常后,我添加了以下 post 构建事件构建命令
dotfuscatorCLI.exe "$(ProjectDir)Dotfuscator.xml"
实现相同结果的另一种方法
上述解决方案将起作用,但它特定于一台计算机。因此,如果您在一个团队中工作,并且有可能在多台机器上构建您的解决方案,那么我更喜欢文章中定义的方法,其 link 在我的问题中被共享。但是,该方法需要进行细微调整。
下面是可以使用的 post 构建命令:
dotfuscatorcli.exe /q
/p=SourceDirectory="$(TargetDir)\",SourceFile=$(TargetFileName)
"$(ProjectDir)Dotfuscator.xml"
请注意这里的 Dotfuscator.xml 是 MSDN 文章中提到的那个,而不是前面解决方案中提到的 dotfuscator.exe 生成的那个。另请注意,如果您的 TargetFileName 包含空格,则在其周围加上双引号。
希望这对其他人有帮助。
我正在尝试通过在 Visual Studio 2015 年使用 post-build 命令来自动混淆。我已按照 this MSDN 文章中的步骤进行操作。
我添加了步骤中提到的 post-build 命令并创建了 Dotfuscator.xml,放置在根目录中,即 vbproj 文件所在的位置。
构建项目后,我收到以下错误消息。
这里是 post-build 命令:
"C:\Program Files (x86)\Microsoft Visual Studio 14.0\PreEmptive Solutions\Dotfuscator and Analytics Community Edition\dotfuscator.exe" /q /p=SourceDirectory=$(TargetDir),SourceFile=$(TargetFileName) $(ProjectDir)Dotfuscator.xml
任何提示或解决方案将不胜感激。
您需要引用您经过的那些路径...
"C:\Program Files (x86)\Microsoft Visual Studio 14.0\PreEmptive Solutions\Dotfuscator and Analytics Community Edition\dotfuscator.exe" /q /p=SourceDirectory="$(TargetDir)",SourceFile="$(TargetFileName)" $(ProjectDir)Dotfuscator.xml
或者也许
"C:\Program Files (x86)\Microsoft Visual Studio 14.0\PreEmptive Solutions\Dotfuscator and Analytics Community Edition\dotfuscator.exe" /q /p="SourceDirectory=$(TargetDir),SourceFile=$(TargetFileName)" $(ProjectDir)Dotfuscator.xml
通过 运行 命令提示符下的 exe 对其进行测试,以查看它如何处理该参数。
现在您已经解决了 Trevor 描述的引用问题,我认为下一个问题是您可能 运行 一个没有 command-line 支持的 Dotfuscator 版本.
Visual Studio 2015 Update 3(和 VS 2017)包括具有 command-line 支持的 Dotfuscator Community Edition (CE) 版本。 (您必须注册才能启用它。)如果您使用的是早期版本的 VS 2015,您可以从 PreEmptive 下载具有 command-line 支持的 Dotfuscator CE 版本;有关详细信息,请参阅 instructions here。
完全披露:我为 PreEmptive Solutions 工作。
在@Trevor 和@Nathan 的回答的帮助下,我在这里能够实现我想要的。
首先,我使用 Dotfuscator.exe 创建了 Dotfuscator.xml 文件。提供输入文件并生成一次混淆 DLL。
确认 XML 文件工作正常后,我添加了以下 post 构建事件构建命令
dotfuscatorCLI.exe "$(ProjectDir)Dotfuscator.xml"
实现相同结果的另一种方法 上述解决方案将起作用,但它特定于一台计算机。因此,如果您在一个团队中工作,并且有可能在多台机器上构建您的解决方案,那么我更喜欢文章中定义的方法,其 link 在我的问题中被共享。但是,该方法需要进行细微调整。
下面是可以使用的 post 构建命令:
dotfuscatorcli.exe /q /p=SourceDirectory="$(TargetDir)\",SourceFile=$(TargetFileName) "$(ProjectDir)Dotfuscator.xml"
请注意这里的 Dotfuscator.xml 是 MSDN 文章中提到的那个,而不是前面解决方案中提到的 dotfuscator.exe 生成的那个。另请注意,如果您的 TargetFileName 包含空格,则在其周围加上双引号。
希望这对其他人有帮助。