CubeCoders / ConfuserEx-Reborn

An open-source, free protector for .NET applications
https://cubecoders.github.io/ConfuserEx-Reborn/
Other
93 stars 11 forks source link

ConfuserEx.CLI cannot use a path with spaces in -out parameter #17

Open LamerTex opened 6 years ago

LamerTex commented 6 years ago

Hi I'm trying to use ConfuserEX.CLI in VisualStudio via a PostBuild Event to confuse the output files of the project. This is the script I'm using: If $(ConfigurationName) == Release+Obfuscated ( $(ProjectDir)..\..\ConfuserEx_bin\Confuser.CLI.exe -n -out=$(TargetDir) $(TargetPath) )

And it is working fine normally. The problems begin when the paths contains some spaces, to use them I need to add " " so the script become:

If $(ConfigurationName) == Release+Obfuscated ( "$(ProjectDir)..\..\ConfuserEx_bin\Confuser.CLI.exe" -n -out="$(TargetDir)" "$(TargetPath)" )

In this way the first and third parameters work again (both the Confuser.CLI.exe and the input module "$(TargetPath)" are found), but the second one, the one that specify the output folder, give the following error:

[ERROR] Unknown error occurred. Exception: System.ArgumentException: Characters not valid in the path. in System.IO.Path.CheckInvalidPathChars(String path, Boolean checkAdditional) in System.IO.Path.Combine(String path1, String path2) in Confuser.Core.ConfuserEngine.RunInternal(ConfuserParameters parameters, CancellationToken token) in C:\Users\MatteoTex\Downloads\ConfuserEx-Reborn-master\Confuser.Core\ConfuserEngine.cs:row 92

So I can't use ConfuserEx when the projects has some spaces in its path... I'm doing something wrong or it is a problem with the control for the -out parameter?

Thanks for the attention, Matteo Tessarotto.

Jimmytbane commented 6 years ago

The issue here might be caused by the scripting language, I can’t see off the bat what that language is, but I assume it is PowerShell, considering you are using Windows.

To make it easier to read your post, can you define what language your script is in in markdown?

I would try a similar script in maybe another scripting language and if you still have issues with -out arguments with spaces.

If all else fails the code can be modified to not crash when it receives such input, I may be able to fix that if time makes it possible.

LamerTex commented 6 years ago

I confirm it is Powershell/windows batch script language because in the "postbuild" event of visual studio in windows that is the used language

jhedlund commented 6 years ago

I had a similar problem with encasing the output directory with quotes, I was able to work around the issue by ensuring there is no trailing backslash in the output directory. It seems the NDesk.Options class that parses the command line escapes that quote if the backslash is there and then fails to correctly parse the rest of the line.