0
votes

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.

I've added the post-build command as mentioned in steps and created Dotfuscator.xml, placed in root directory i.e. where vbproj file is located. Once I build the project I get following error message. enter image description here

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

Any hint or solution will be appreciated.

3

3 Answers

1
votes

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

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

Test it by running the exe from the command prompt to see how the thing handles that argument.

1
votes

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.

Visual Studio 2015 Update 3 (and VS 2017) includes a version of Dotfuscator Community Edition (CE) that has command-line support. (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; see the instructions here for details.

Full disclosure: I work for PreEmptive Solutions.

1
votes

With the help of answers from @Trevor and @Nathan, here I'm able to achieve what was desired.

  1. First I created the Dotfuscator.xml file using Dotfuscator.exe. Providing input files and generated obfuscated DLL once.

  2. Once it's confirmed that the XML file working fine, I then added following post build event build command

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. However that approach requires a minor tweak.

Here is the post build command that will work:

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. Also note, if your TargetFileName contains spaces then put double quotes around it.

Hope this would help others.