Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Illegal characters in path for nuget pack

Tags:

nuget

msbuild

I'm packing an application using Cruise Control, the command is like this

<Exec Command="$(NugetToolPath) pack &quot;@(NuSpecs)&quot; -OutputDirectory \\servername\PackageSource -BasePath &quot;%(NuSpecs.RootDir)%(NuSpecs.Directory)&quot; -NoPackageAnalysis" />

Iv'e narrowed down the error to be the BasePath it comes out as

-BasePath "D:\Code\Mobile_Trunk\PreCompiledWeb\Portal\Mobile LT Admin\"

I know the issue because it should be

-BasePath "D:\Code\Mobile_Trunk\PreCompiledWeb\Portal\Mobile LT Admin"

but because I'm using .Directory metadata it will always return with a \ at the end

I normally wouldn't quote the base path, but since there are spaces in the directory, I have no choice. Is there a way around this? I don't know any other metadata which will return the full folder strucutre other than how I've layed it out

UPDATE:

I came to this solution, it's still not helped my knowledge on how to get around the issue with the illegal path, but it works.

<Exec Command="$(NugetToolPath) pack &quot;%(NuSpecs.RootDir)%(NuSpecs.Directory)%(Nuspecs.FileName).nuspec&quot; -OutputDirectory \\servername\PackageSource  -NoPackageAnalysis" />
like image 358
Lewis Avatar asked Jun 26 '13 13:06

Lewis


2 Answers

Just insert a space after the directory and before the quote character:

-OutputDirectory "\\servername\PackageSource\ " 

See the accepted answer here (the question itself isn't highly relevant but the answer is):

How to accept command-line args ending in backslash

This fascinating reference is also linked to in another answer on that question:
http://www.daviddeley.com/autohotkey/parameters/parameters.htm#WINCRULESDOC

like image 158
Brian Lacy Avatar answered Nov 13 '22 10:11

Brian Lacy


We got this error when we executed nuget restore from Jenkins, where we ran a JNLP agent on the slave-node.

Turns out that "Path" in Illegal characters in path means the PATH environment variable, and in our case nuget.exe was inheriting a PATH variable that had quotes in it, i.e. something like:

Path=C:\Program Files\foo;"C:\Program Files\bar"

If you are using Jenkins, add echo %PATH% to be executed somewhere by Jenkins, and check if it has any funny characters.

like image 2
sashoalm Avatar answered Nov 13 '22 10:11

sashoalm