System.FormatException error when executing nuget push

Sep 8, 2011 at 7:39 AM

We have set up an internal repository, using NuGet.Server v1.5.20818.9011

When I try to push a package to this repository using the command:

nuget.exe push MyPackage.1.0.36 MyRepositoryPassword -src http://ourserver/nuget

I get an error  :

Onverwerkte uitzondering: System.FormatException: De indeling van de invoertekenreeks is onjuist.
   bij System.Text.StringBuilder.AppendFormat(IFormatProvider provider, String format, Object[] args)
   bij System.String.Format(IFormatProvider provider, String format, Object[] args)
   bij System.IO.TextWriter.WriteLine(String format, Object[] arg)
   bij System.IO.TextWriter.SyncTextWriter.WriteLine(String format, Object[] arg)
   bij NuGet.Common.Console.WriteColor(TextWriter writer, ConsoleColor color, String value, Object[] args)
   bij NuGet.Common.Console.WriteError(String value)
   bij NuGet.Program.Main(String[] args)

Sep 8, 2011 at 8:01 AM

From the stack, it looks like it's failing while trying to display an error, so you're not seeing the true error (not sure why).

One thing that looks wrong: it should be push MyPackage.1.0.36.nupkg (i.e. the file name, possibly with path) instead of push MyPackage.1.0.36.

Sep 8, 2011 at 9:00 AM

I was issueing the push command with the extension (just forget it while writing the post)

But I found the cause ... 

The first time, I published the package to the server, using file copy paste, on the server.

The second time I tried publishing (the same version) with nuget push.. , and it was trying to overwrite the package file on the server, but due to the initial file/copy, the package's file permissions did not allow the web application to overwrite this file.
After deleting the package on the server, the error dissappeared. 

we are still experimenting with nuget, it is not yet in production, so I was trying both methods of publishing ...

Sep 8, 2011 at 2:37 PM

There seems to be a bug in nuget.exe error handling, I saw this once myself.

Sep 8, 2011 at 5:59 PM

If anyone finds a repro of that error reporting issue, it'd be good to address it.

Sep 8, 2011 at 6:08 PM

If anyone wants to fix it, we accept pull requests as well :D.

Sep 8, 2011 at 6:30 PM
Edited Sep 8, 2011 at 6:31 PM

The relevant code is likely to be in src\CommandLine\Program.cs:


            catch (Exception e) {
                return 1;

Write error expects a format string, but we're passing an arbitrary message, with is incorrect. e.g. if the message happens to contain a {, it will blow up (needs to be escaped as {{). It would be best not to call something that takes a format string at all.

Sep 8, 2011 at 7:20 PM

@davidebbo: Please submit pull request. :)