I'm working on a C# WPF project and I need some obfuscation. I found Obfuscar and it looks very promising, using nuget and a post-build event seems like a solid solution. So I've installed the nuget package and added and tweaked the obfuscar.xml file in such a way that it should work.
However, the post build command refers to the macro $(Obfuscar)
, which is not recognized. Now when I build my project, I get the following build error:
The command " obfuscar.xml" exited with code 9009.
Please note the empty space after the first quotation marks: $(Obfuscar)
can obviously not be resolved somehow.
I tried all steps described by the docs and on other websites, including putting the macro inside quotation marks, but I just can't get it to work.
-- edit --
What I've done: - installed the Obfuscar nuget - added obfuscar.xml file with basic configuration - added post-build event - try to build
What I've tried in terms of post-build events:
$(Obfuscar) obfuscar.xml
The command " obfuscar.xml" exited with code 9009.
"$(Obfuscar)" obfuscar.xml
The command """ obfuscar.xml" exited with code 9009.
I've tried to build and run the example project and that works perfectly. I've copy-pasted the post-build event (not the xml file) from the example project to my project but that just gives the same results.
What I don't understand either is how Visual Studio could possibly know what $(Obfuscar)
means or how to resolve it to the path of the Obfuscar executable. Do I need some kind of configuration for that somewhere or is it some special kind of black magic that should just work?
-- edit 2 --
I've kind of got it to work now by copying the Obfuscar executable from the nuget folder to a folder in my PATH (C:\Windows for now) as "obfuscar.exe" and simply use the post-build command obfuscar obfuscar.xml
. I say kind of because actually using the nuget instead of a copied executable is that now I don't have automatic updates. Now when a new version comes out, I'll have to copy/paste it manually. Guess I'll have to add that to the readme file for now until a better solution comes up.