Archived

This forum has been archived. Please start a new discussion on GitHub.

Pre-Build needs no spaces!

I noticed that if i did a prebuild in a directory like C:\Documents and Settings it would fail because it thaught you were doing another argument.. a possible way to fix this would be like:
generate.exe --solutionDir=C:\Documents and settings--ProjectDir=C:\Documents and Settings\project--ProjectName=project

Comments

  • Ah, thanks for the bug report. Most likely, the solution is to put double quotes around the arguments used in the pre-build step in each project. (Your suggestion won't work because, by the time the arguments are passed to generate.cs, they are broken into separate tokens where the spaces are already.) I'll try this on Monday morning when I get to the office.

    Bloody spaces in file names -- they've never been a good idea and confuse all sorts of tools...

    Cheers,

    Michi.
  • Originally posted by michi

    Bloody spaces in file names -- they've never been a good idea and confuse all sorts of tools...

    Yeah, I totally agree with you. I'll try the spaces and see what happens.
  • I tried various quoting tricks to allow the code to be built if the source tree is installed somewhere where a directory name contains a space, but to no avail. The problem isn't with generate.cs, but with the way Visual C# parses command-line arguments for the pre-build step. While it correctly invokes the generate.exe program if I put double quotes around the executable path in the pre-build step, it incorrectly breaks the executable name into to separate arguments where the space is, so generate.exe (correctly) concludes that it has been given invalid arguments.

    For example, if you rename the root directory (icecs) to (ice cs) and try to build, you get a pre-build failure because generate.exe is not found. If you then put double quotes around the command in the pre-build step, generate.exe is executed, but the command-line argument then are:

    [0] @C:\cygwin\home\michi\src\ice
    [1] @cs\
    [2] @C:\cygwin\home\michi\src\ice
    [3] @cs\src\Ice\
    [4] "Ice"

    Note that Visual C# splits the first argument into two arguments, which is simply wrong.

    This is a bug in Visual C#, and I don't believe there is a fix. My only suggestion is not to build in a directory hierarchy where a directory name contains a space.

    Cheers,

    Michi.
  • I have an idea, this is what i did with a similar "echo" command for one of my control panels. I would rebuild the string array. Like so.. (assume args is the argument array)
    string text = "";
    foreach(string arg in args)
    {
    	if(text == "")
    	{
    		text += arg;
    	}
    	else
    	{
    		text += " " + arg;
    	}
    }
    
    Sort of a hack job but it did the trick for me.

    **edit again**

    I'll add the processing code too. Then assume that each argument would be prepended with a ":" (not allowed in folder names).
    string[] arguments = text.Split(char.Parse(":"));
    [i]solution_dir[/i] = arguments[0];
    [i]project_dir[/i] = arguments[1];
    [i]project_name[/i] = arguments[2];
    [i]arguments[/i] = arguments[3];
    

    **end of edit**
  • Well, maybe some sort of hack along those lines would work. But, to be honest, I'd rather just say "don't build Ice in a directory that has a space in its name". That's a lot easier and doesn't require writing any code :)

    Cheers,

    Michi.
  • Alright, I was just letting you know.