2
votes

I am trying to automatically dotfuscate my projects during the build process in TFS.

I have created a "Post-Build Event" under the project properties as follows:

"C:\Program Files (x86)\PreEmptive Solutions\Dotfuscator Professional Edition 4.9\dotfuscator.exe" /in:"$(TargetPath)" /out:"$(TargetDir)Obfuscated\" /honor:on /strip:on /prune:off /rename:off /suppress:on /mapout:"$(TargetFileName).xml" /debug:pdb xcopy /S /R /Y "$(TargetDir)Obfuscated\$(TargetFileName)" "$(TargetDir)"

When this event kicks off I get the following error:

"C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Microsoft.Common.targets (3717): The command ""C:\Program Files (x86)\PreEmptive Solutions\Dotfuscator Professional Edition 4.9\dotfuscator.exe" /in:"C:\Builds\5\BIMS\Sandbox Branch Private Test Manual Build\Binaries\ProcessBookmarks.exe" /out:"C:\Builds\5\BIMS\Sandbox Branch Private Test Manual Build\Binaries\Obfuscated\" /honor:on /strip:on /prune:off /rename:off /suppress:on /mapout:"ProcessBookmarks.exe.xml" /debug:pdb xcopy /S /R /Y "C:\Builds\5\BIMS\Sandbox Branch Private Test Manual Build\Binaries\Obfuscated\ProcessBookmarks.exe" "C:\Builds\5\BIMS\Sandbox Branch Private Test Manual Build\Binaries\"" exited with code 4."

I have done hours of research, experimentation, and googling on this subject and have not been able to figure out explaination for the error. When I run the build locally the command works just fine. Any help would be greatly appreciated

Edit: I have made several more attempts at getting dotfuscator to work via command line. I have ensured that the dotfuscator command works by itself locally, but when I run the build definition the dotfuscator command line exits with code 1 as follows, and I have no idea how to fix it:

C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Microsoft.Common.targets (3717): The command ""C:\Program Files (x86)\PreEmptive Solutions\Dotfuscator Professional Edition 4.9\dotfuscator.exe" /in:"C:\Builds\5\BIMS\Sandbox Branch Private Test Manual Build\Binaries\ProcessBookmarks.exe" /out:"C:\Builds\5\BIMS\Sandbox Branch Private Test Manual Build\Binaries\Obfuscated" /honor:on /strip:on /prune:off /enhancedOI:on /suppress:on /mapout:"C:\Builds\5\BIMS\Sandbox Branch Private Test Manual Build\Binaries\ProcessBookmarks.exe.xml" /debug:pdb" exited with code 1.

I am still having trouble with getting dotfuscator to work in my automated builds, does anyone have an example of how they are doing it. I would really appreciate an answer to this question.

1
Can you share what is shown in your Output Window? - Morten Frederiksen
I have removed the xcopy command and tried running just the dotfuscator command. The command works locally and correctly dotfuscates the file and puts it in the correct folder, however when I run the actual build definition I get an exited with code 1 now. There is no additional information that I can see available in the build log file or output window to share. - Aaron Davis

1 Answers

1
votes

I would suggest using copy rather than xcopy to copy your obfuscated dlls to your output folder.

The reason I suggest this is because I have spent the day trying to do the same as you, except I have Dotfuscator projects (*.dotfuproj) in my solution (rather than calling Dotfuscator via the commandline in the post build step) and I was trying to copy the Dotfuscator output during the Dotfuscator projects post build step.

When I used xcopy it failed to copy the file with no warning, error or message of any sort. It just continued like nothing happened - no positive or negative output. Nothing.

Executing the xcopy command via the command line worked fine - nothing made sense as to why xcopy did not work and why I got no message indicating why. [If anyone know why this is I would love to know]

With copy you need to specify the destination file rather than just the directory as you have above in your xcopy command.

[I would have added this as a comment to your question but I don't appear to have the ability/rep(?)]