What’s a solution-level package?
A solution-level package is one that installs a tool or additional commands for the Package Manager console, but does not add references or content to any projects in your solution. For example, the psake package installs PowerShell scripts you can use to automate your build process.
A package is considered a solution-level package if it does not contain any files in its lib or content directories. If the package has dependencies, they also must not have files in their lib or content directories.
When a solution-level package is installed, it is tracked in a packages.config file in the .nuget directory, rather than in a packages.config file in a specific project.
We have the limitation that build cannot restore solution packages. But through VS you can use the button to restore, and from the command line you can run nuget.exe install from the .nuget folder.
It works from Visual Studio…yes!
But on the build server…there’s no Visual Studio and fancy buttons to press so we have to use nuget.exe instead, let’s see how!
As the title of this blog post hints we’re using the power of TeamCity to enable, or overcome the by-design issues of NuGet, package restore for solution packages.
However you could apply this “fix” in any situation (or build server) where you can run an executable. TeamCity just makes it pretty easy.
Given that you have your .nuget folder (nuget.exe, packages.config at least) in source control all you have to-do is this:
- Add a new build step (Command-Line)
- Set the working directory to the .nuget folder
- Run nuget.exe
- With these parameters:
install packages.config –o ..\packages
note: -o ..\packages is the path where the output should be placed (the packages folder is usually a good place)
After you’ve created the new build step you need to put it first (or at least before your compile step) as the following image shows.
You can also use the technique used in this post.