Nuget Command Line Error: Value cannot be null. Parameter name: format.

Jul 12, 2011 at 5:22 PM

Hello,

I am using a Local Repository in VS 2010 with the usual packages I use.

To download those packages to the Local Repository Source folder I am using the following Batch File:

Nuget Update -Self

Nuget Install EntityFramework -Version 4.1.10331.0 -OutputDirectory .\Source
Nuget Install FluentValidation -Version 3.0.0.1 -OutputDirectory .\Source
Nuget Install FluentValidation.MVC3 -Version 3.0.0.1 -OutputDirectory .\Source
Nuget Install Moq -Version 4.0.10827 -OutputDirectory .\Source
Nuget Install StructureMap -Version 2.6.2 -OutputDirectory .\Source

Pause

When I run this code the first time everything works fine. I have a few questions:

1 - Later I added a new package to this file. When I run this script I get an error in packages that were already installed:

     Value cannot be null. Parameter name: format.

     How can I solve this?

2 - Is there another way, besides using a Batch File, to do this?

     Maybe using a Power Shell script? Maybe called by the the Batch file?

3 - Sometimes I might want to update one of the packages.

     I would like to replace the version in the file, run it and it would be updated.

Could someone tell me how to accomplish these?

Thank You,

Miguel

 

 

 

Jul 12, 2011 at 5:33 PM

I'm not sure the install command is right for you if you all you want is to get the package files in a folder. Install creates folders and extracts most of the content. There was talk of adding a Download command, but I'm not sure where it stands.

Can you give more details about the error in #1? What are the exact steps that lead to seeing this? Does it repro consistently?

Thanks,
David

Jul 12, 2011 at 5:44 PM
davidebbo wrote:

I'm not sure the install command is right for you if you all you want is to get the package files in a folder. Install creates folders and extracts most of the content. There was talk of adding a Download command, but I'm not sure where it stands.

What options do I have?

I would like to have a local repository for all packages I use.

And I would like to be able to get the packages inside my local repository.

 

About the steps:

1 - Run the batch. All packages are installed.

2 - Run the batch again and you get the error in all packages that were previously installed.

Yes it is a consistent error.

Thank you,

Miguel

Jul 12, 2011 at 5:56 PM
davidebbo wrote:

I'm not sure the install command is right for you if you all you want is to get the package files in a folder. Install creates folders and extracts most of the content. There was talk of adding a Download command, but I'm not sure where it stands.

The only download option I found was this:

  http://weblogs.asp.net/jgalloway/archive/2011/02/02/downloading-a-local-nuget-repository-with-powershell.aspx

And the package:

  http://nuget.org/List/Packages/Nuget.Downloader

But this downloads all packages from NuGet.

And I was looking for a way to download specific packages.

Thank you,

Miguel

 

Coordinator
Jul 12, 2011 at 5:59 PM

I believe package explorer does that. http://npe.codeplex.com/

Jul 12, 2011 at 6:03 PM

I'm not able to repro this "Value cannot be null. Parameter name: format" error by running your batch file twice. Does it repro for you if you simply run 'Nuget Install EntityFramework' twice in a row from the command line?

Jul 12, 2011 at 6:12 PM
davidebbo wrote:

I'm not able to repro this "Value cannot be null. Parameter name: format" error by running your batch file twice. Does it repro for you if you simply run 'Nuget Install EntityFramework' twice in a row from the command line?

If you remove the version it works fine.

If you run the following twice then you get the error:

Nuget Install EntityFramework -Version 4.1.10331.0
Pause

Jul 12, 2011 at 6:17 PM
Haacked wrote:

I believe package explorer does that. http://npe.codeplex.com/

Yes, I can open a package and then save the metadata.

I was just trying to download files using nuget command line.

But that would do to.

Thank you,

Miguel

Jul 12, 2011 at 7:36 PM

I do not see this. e.g.

D:\test>Nuget Install EntityFramework -Version 4.1.10331.0
Successfully installed 'EntityFramework 4.1.10331.0'.

D:\test>Nuget Install EntityFramework -Version 4.1.10331.0
'EntityFramework 4.1.10331.0' already installed.

The second attempt to install should just find that it's already there and return instantly.

Jul 12, 2011 at 9:22 PM
Edited Jul 13, 2011 at 1:40 PM
UPDATE: This is incorrect (Nuget.exe does not exit with a non-zero code). See further down in the discussion where this is tested and proven to be wrong.
You are correct, when a package is already installed, nuget.exe returns a non-zero exit code (as if it were an error). Whether this is a bug or expected behavior I do not know.
This means that a simple batch will stop on the first one every time and go no further.
Solution: Use powershell. Here is an example of calling a powershell file from a cmd (or batch file): https://github.com/ferventcoder/nugetpackages/blob/master/chocolateyInstall/installChocolatey.cmd
Jul 12, 2011 at 9:28 PM
ferventcoder wrote:
You are correct, when a package is already installed, nuget.exe returns a non-zero exit code (as if it were an error). Whether this is a bug or expected behavior I do not know.
This means that a simple batch will stop on the first one every time and go no further.
Solution: Use powershell. Here is an example of calling a powershell file from a cmd (or batch file): https://github.com/ferventcoder/nugetpackages/blob/master/chocolateyInstall/installChocolatey.cmd

Well, I just can't repro this. If I put the exact commands in the initial post in a foo.cmd batch file and run it twice, it works just fine without errors. Also @shapper says that it repros for him by just directly running the one command without batch file, so I'm thinking something else is going on here.

Jul 12, 2011 at 9:53 PM

Hi David,

I just sent you an email with the files I am using. Maybe it helps ...

ferventcoder,

I am going to take a look.

In fact I have been trying Chocolatey today.

Thank You,

Miguel

Jul 12, 2011 at 9:57 PM

Oops the email was rejected I think because of sending a zip.

Well, here it is: NuGet

Thanks,

Miguel

Jul 12, 2011 at 10:01 PM
Edited Jul 12, 2011 at 10:04 PM

It does not repro for me with your batch file. But in any case, we have established that the batch file was irrelevant since you confirmed above that you were able to repro by just running the command directly. Do others repro this or not?

Jul 12, 2011 at 10:07 PM

Yes that happens even if typing on command prompt directly ...

First time works. And if fails second time and from that on.

Jul 12, 2011 at 10:32 PM

If you are able to try debugging it, it would be interesting to see the stack where this gets thrown.

Jul 13, 2011 at 1:35 PM
Edited Jul 13, 2011 at 1:35 PM

Look at your nuget.exe version: 1.5.

I can use your batch and repro every time (as long as I tell it to use the nuget in this directory and not one I have on the path).

@echo off
SET DIR=%~d0%~p0%
"%DIR%Nuget.exe" Install EntityFramework -Version 4.1.10331.0

Pause

Jul 13, 2011 at 1:36 PM

You should be using the official published nuget.exe 1.4. Please try downloading it and trying again.

Jul 13, 2011 at 1:38 PM
Edited Jul 13, 2011 at 1:40 PM

NuGet does exit with a zero code. Nevermind on the non-zero exit code. I was incorrect on that.

Here's how I tested it:

@echo off
SET DIR=%~d0%~p0%

"%DIR%Nuget.exe" Update -Self
if %ERRORLEVEL% NEQ 0 goto errors

"%DIR%Nuget.exe" Install EntityFramework -Version 4.1.10331.0 -OutputDirectory .\Source
if %ERRORLEVEL% NEQ 0 goto errors

"%DIR%Nuget.exe" Install FluentValidation -Version 3.0.0.1 -OutputDirectory .\Source
if %ERRORLEVEL% NEQ 0 goto errors

"%DIR%Nuget.exe" Install FluentValidation.MVC3 -Version 3.0.0.1 -OutputDirectory .\Source
if %ERRORLEVEL% NEQ 0 goto errors

"%DIR%Nuget.exe" Install Moq -Version 4.0.10827 -OutputDirectory .\Source
if %ERRORLEVEL% NEQ 0 goto errors

"%DIR%Nuget.exe" Install StructureMap -Version 2.6.2 -OutputDirectory .\Source
if %ERRORLEVEL% NEQ 0 goto errors

goto finish

:errors
ECHO %ERRORLEVEL%EXIT /B %ERRORLEVEL%

:finish
Pause

Jul 13, 2011 at 1:43 PM

RE chocolatey: Chocolatey has a different purpose than NuGet. Chocolatey is for tools and applications and not necessarily developer focused where nuget is for libraries and content supporting making the tools and applications for chocolatey. ;)

Jul 13, 2011 at 1:45 PM

Might want to view discussion on the emails, I had to fix some formatting... :(

Jul 13, 2011 at 1:48 PM
ferventcoder wrote:

You should be using the official published nuget.exe 1.4. Please try downloading it and trying again.

I was using NuGet 1.5 because I was following a post about NuGet command line from David's blog.

And I found out that I could be up to date with the command "Nuget Update -Self" which I posted on my first message.

I though that wouldn't be a problem ...

Jul 13, 2011 at 1:50 PM
ferventcoder wrote:

RE chocolatey: Chocolatey has a different purpose than NuGet. Chocolatey is for tools and applications and not necessarily developer focused where nuget is for libraries and content supporting making the tools and applications for chocolatey. ;)

Yes, I found about Chocolatey when trying to install the package AspNetMvc.

I was trying to do it using a NuGet ... But then some installation started to take place even if MVC 3 is already installed and I ended up using just a reference to the dll library.

Jul 13, 2011 at 1:53 PM
I run nuget update -self against 1.4 and it does not update to nuget 1.5.
I run nuget update -self against 1.5 and it does not go down to 1.4 or report that I am using a version that is not yet released.
Jul 13, 2011 at 1:54 PM
Well at least aspnetmvc was a non-silent install so you could stop it immediately. I should probably rename that to something else to alleviate confusion for others.
Jul 13, 2011 at 2:05 PM
ferventcoder wrote:
I run nuget update -self against 1.4 and it does not update to nuget 1.5.
I run nuget update -self against 1.5 and it does not go down to 1.4 or report that I am using a version that is not yet released.

Correct. I found why I was using NuGet 1.5. On David's blog there is a link to download NuGet:

http://blog.davidebbo.com/2011/01/nugetexe-is-now-self-updatable.html

And I ended up with version 1.5. I though I was getting version 1.4 and when running update -self that it was updated to version 1.5.

Jul 13, 2011 at 2:09 PM
I see the link to the latest from the build server in the post. If you downgrade to the published version, the scripts work fine.
Jul 13, 2011 at 8:23 PM

Ok, so it seems there are a few distinct issues here:

  1. My post pointing to the CI Server build. I just changed it to point to the Codeplex download.
  2. The fact that the CI build is broken. We definitely need to fix that!
  3. The fact that running update doesn't tell you when you already have a newer version than what's available. We could add a message.
Jul 13, 2011 at 8:25 PM
This discussion has been copied to a work item. Click here to go to the work item and continue the discussion.