简体   繁体   English

通过在Visual Studio中使用生成后命令进行自动化混淆

[英]Obfuscation Automation by Using Post-Build Commands in Visual Studio

I'm trying to automate obfuscation by using post-build commands in Visual Studio 2015. I've followed the steps from this article on MSDN. 我试图通过在Visual Studio 2015年。我已经按照从步骤生成后命令来自动模糊处理文章在MSDN上。

I've added the post-build command as mentioned in steps and created Dotfuscator.xml, placed in root directory ie where vbproj file is located. 我添加了步骤中提到的post-build命令,并创建了Dotfuscator.xml,并将其放置在根目录(即vbproj文件所在的位置)中。 Once I build the project I get following error message. 构建项目后,我将收到以下错误消息。 在此处输入图片说明

Here is the post-build command: 这是构建后命令:

"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

Any hint or solution will be appreciated. 任何提示或解决方案将不胜感激。

You need to quote those paths you are passing... 您需要引用您通过的路径...

"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

Or Perhaps 也许

"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

Test it by running the exe from the command prompt to see how the thing handles that argument. 通过在命令提示符下运行exe进行测试,以查看事物如何处理该参数。

Now that you've sorted out the quoting issue as Trevor described, I think the next issue is that you're probably running a version of Dotfuscator that doesn't have command-line support. 现在,您已经按照Trevor的描述整理了报价问题,我认为下一个问题是您可能正在运行的Dotfuscator版本没有命令行支持。

Visual Studio 2015 Update 3 (and VS 2017) includes a version of Dotfuscator Community Edition (CE) that has command-line support. Visual Studio 2015更新3(和VS 2017)包括具有命令行支持的Dotfuscator社区版(CE)版本。 (You have to register to enable it.) If you're using an earlier version of VS 2015, you can download a version of Dotfuscator CE that has command-line support from PreEmptive; (您必须注册才能启用它。)如果使用的是VS 2015的早期版本,则可以从PreEmptive下载具有命令行支持的Dotfuscator CE版本。 see the instructions here for details. 有关详细信息,请参见此处的说明。

Full disclosure: I work for PreEmptive Solutions. 全面披露:我为PreEmptive Solutions工作。

With the help of answers from @Trevor and @Nathan, here I'm able to achieve what was desired. 借助@Trevor和@Nathan的答案,在这里我可以实现所需的功能。

  1. First I created the Dotfuscator.xml file using Dotfuscator.exe. 首先,我使用Dotfuscator.exe创建了Dotfuscator.xml文件。 Providing input files and generated obfuscated DLL once. 提供输入文件并生成一次混淆的DLL。

  2. Once it's confirmed that the XML file working fine, I then added following post build event build command 确认XML文件可以正常工作后,我随后添加了以下build build event build命令

dotfuscatorCLI.exe "$(ProjectDir)Dotfuscator.xml" dotfuscatorCLI.exe“ $(ProjectDir)Dotfuscator.xml”

Another way to achieve same results Above solution will work but it would be specific to one computer. 获得相同结果的另一种方法以上解决方案可以工作,但它特定于一台计算机。 So if you are working in a team and there are chances that you build your solution on multiple machines then I would prefer the approach defined in the article whose link was shared in my Question. 因此,如果您在一个团队中工作,并且有机会在多台计算机上构建解决方案,那么我希望使用本文中定义的方法,该方法的链接在我的Question中共享。 However that approach requires a minor tweak. 但是,该方法需要进行一些细微调整。

Here is the post build command that will work: 这是将起作用的post build命令:

dotfuscatorcli.exe /q /p=SourceDirectory="$(TargetDir)\\",SourceFile=$(TargetFileName) "$(ProjectDir)Dotfuscator.xml" dotfuscatorcli.exe / q / p = SourceDirectory =“ $(TargetDir)\\”,SourceFile = $(TargetFileName)“ $(ProjectDir)Dotfuscator.xml”

Please note here the Dotfuscator.xml is the one that is referred in the MSDN article, not the one generated by dotfuscator.exe as mentioned in previous solution. 请注意,此处的Dotfuscator.xml是MSDN文章中所引用的,而不是先前解决方案中提到的dotfuscator.exe生成的。 Also note, if your TargetFileName contains spaces then put double quotes around it. 还要注意,如果您的TargetFileName包含空格,请在其周围加上双引号。

Hope this would help others. 希望这对其他人有帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM