I love Chocolatey. As many have said “it’s like apt-get for windows” and for the most part it just works. Kudos to Rob Reynolds for putting it together.

Get your minClientVersion attribute on

This week while working on a side project I ran into a known issue with the newly added minClientVersion attributes in nuspec files.

1
2
3
4
5
6
7
C:\dev\marv.git\src\Marv> cpack
Calling 'C:\Chocolatey\chocolateyInstall\nuget.exe pack  -NoPackageAnalysis'.
Attempting to build package from 'Marv.csproj'.
Packing files from 'C:\dev\marv.git\src\Marv\bin\Debug'.
Using 'Marv.nuspec' for metadata.
The 'minClientVersion' attribute is not declared.
Reading environment variables from registry. Please wait... Done.

A quick google on the error message turned up this post to the chocolatey google group, but after clearing my nuget cache the problem persisted so I turned to investigate the version of nuget.exe.

When I ran nuget pack in my project folder it completed no trouble.

Running nuget alone showed me I was using version 2.7.41115.310 which at the time is tagged as version 2.7.3 and is the most up-to-date release available. So clearly the nuget client on my machine was able to package up my project.

Still, when I ran cpack which aliases to chocolatey pack it failed with the error above: The 'minClientVersion' attribute is not declared.

Which nuget client was that?

It turns out that the Chocolatey-Pack command (and probably several other chocolatey nuggets of goodness) use their own copy of nuget.exe located at the path included in the output above.

Running c:\chocolatey\chocolateyInstall\nuget.exe showed me that nuget client was at version 2.1.31022.9038

Aha!

Update your chocolatey nuget client

Running c:\chocolatey\chocolateyInstall\nuget.exe update -self updated that chocolatey nuget client.

1
2
3
4
5
C:\users\davida\dev\marv.git\src\Marv> C:\Chocolatey\chocolateyInstall\NuGet.exe update -self
Checking for updates from https://nuget.org/api/v2/.
Currently running NuGet.exe 2.1.0.
Updating NuGet.exe to 2.7.3.
Update successful.

Nice package!

And finally, running cpack in my project folder now completed without a hitch.

1
2
3
4
5
6
7
8
9
C:\users\davida\dev\marv.git\src\Marv> cpack
Calling 'C:\Chocolatey\chocolateyInstall\nuget.exe pack  -NoPackageAnalysis'.
Attempting to build package from 'Marv.csproj'.
Packing files from 'C:\users\davida\dev\marv.git\src\Marv\bin\Debug'.
Using 'Marv.nuspec' for metadata.
Found packages.config. Using packages listed as dependencies
Successfully created package 'C:\users\davida\dev\marv.git\src\Marv\marv.0.2.1.0.nupkg'.
 
Reading environment variables from registry. Please wait... Done.

Long story short, you can have many versions of nuget.exe on your machine so if nuget starts behaving funny it’s important to know which nuget client is throwing the error!