CommandLineBuilder seems to be enclosing my parameters in quotes even if they already exist

I'm implementing the makeProgramCommandLine method and in my list of arguments I have an msbuild parameter that is already quoted.  The commandlinebuilder seems to add its own quotes which cause my command line execution to fail

For example I might have the following values:

getExecutablePath : "C:\Windows\Microsoft.NET\Framework64\v4.0.30319\msbuild.exe"


getArguments : C:\test\msbuild.xml
                       /p:SamplePath="C:\another path"
                       /p:debug=true
                       /p:LoggingFile="C:\temp\logging.log"

and when I look into the teamcity logs the following command is being run:

C:\Windows\Microsoft.NET\Framework64\v4.0.30319\msbuild.exe  C:\test\msbuild.xml "/p:SamplePath="C:\another path"" /p:debug=true /p:LoggingFile="C:\temp\logging.log"


It seems that if the path has a space (ie..needs to be covered in quotes), teamcity adds quotes to the argument, even if they already exist.

Thanks.

3 comments
Comment actions Permalink

CommandLineBuilder utility is used to quote parameters in the right way.

To tell the truth, quoting a part of parameter is not the right way of quoting commandline arguments. The right thing is to quote entire argument,
i.e.

para="foo/bar"

should be transfered to

"para=foo/bar"

So, everything would be right if you simple ommit quotes in parameter you put to commandline builder.

Could you please unveil some details of the task you trying to implement. I noticed you were playing with msbuild.exe, in TeamCity there are msbuild runner and VS Solution build runners for msbuild.

0
Comment actions Permalink

The reason that I posted was because I tried to enclose the msbuild parameters in quotes like you suggested ie.. "/p:Path=..." but it didn't seem to work. I've just tried again with a quick sample (I'm at work atm) and it does seem to work. I must have been doing something wrong last night.  I'll make the change when I get home.

I'm using msbuild under the hood for my StyleCop plugin.  Out of interest does the msbuild runner expose any api?  (Though even if it did, not sure it would give me much)

Thanks for your help.

0
Comment actions Permalink

I remember know why it didn't work when I tried it. I had to put quotes where I did was because the parameter I am passing in, is itself a collection of values.  If you have a look at this post on StackOverflow you'll see what I mean. (http://stackoverflow.com/questions/6051054/how-do-i-pass-a-property-to-msbuild-via-command-line-that-could-be-parsed-into-an).  In my plugin the parameter I am passing in is actually a collection of files /p:SourceFiles=C:\temp\ some file.log;C:\temp\ some other file.log.

0

Please sign in to leave a comment.