Enabling Using NuGet Without Checking In Packages Folder

This spec covers how NuGet plans to enable a more “Maven” style workflow for those who do not wish to check-in their packages folder. While the current recommended approach is to check-in the packages folder to ensure a repeatable build without dependencies on any external systems, the NuGet team recognizes the need to support an alternative model without negatively affecting the original model.

We’ll be implementing this workflow in a series of iteration releases starting with the following feature in NuGet 1.4. In the meanwhile, do read David Ebbo’s blog post on how to do this today using NuGet.exe.

Restore Packages from packages.config

Work Item: 165

Discussion Thread

Problem Statement

When installing packages into a project, NuGet creates a packages.config file within the project which serves as a record of exactly what packages are installed in the project. At the same time, a folder for the package is created within the solution level packages folder containing the package and its contents. Currently, it’s expected that the packages folder is checked into source control. The reason for this is that certain files from the package, such as assemblies, are referenced from the packages folder. That way, a package that is installed into multiple projects does not copy the assembly into each project. Instead, all the projects reference the same assembly in one location.

If another user gets latest from source control, and the packages folder is missing, the project would fail to build because the referenced assembly would be missing.

Feature Solution

This new feature will make it so that if the packages folder (or any package folder within the packages folder) is missing,  the packages folder (or missing package folder) will automatically be restored when compiling the application. This ensures that the application will compile even though the packages folder was missing at the time.

Settings

Solution level menu to Convert Solution to Restore Packages.There is no going back. once you run it, the menu option goes away.

Requirements:

  • Works outside of Visual Studio such as when using MSBuild.exe to compile the solution within a CI server environment.
  • Works in an integrated fashion within Visual Studio. When you compile the project, missing packages are restored.

Notes:

  • Feature is off by default. (Based on feedback, seems like it’s safest to leave this off. People using current model want the build to be broken if you forget to check in packages)
  • Enabling the feature turns off the TFS stuff.
  • Adding new projects: We need to hook it and do the right thing.
  • .nuget folder parallel to the packages folder.
    • Contents of this folder are added to a Solution folder: .nuget
    • Contents: NuGet.exe, NuGet.Settings.targets, NuGet.targets
  • When restore is enabled, we should restore packages when we detect installed packages are missing. Such as when they launch the dialog or try to use the package manager console.
  • Privacy issues?

Workflow

1. Install Package First Time
    a) Adds Nuget.config and NuGet Build Target (within NuGet.exe) to Solution level (within Solution Folder)
    b) Adds custom build task

2. Build from VS or msbuild.exe
    a) BeforeBuildTarget: Checks packages.config for the project.
    b) Attempts a restore if any packages are missing.

Assumptions:

  • This doesn't apply to Websites. doesn't break WebMatrix.
  • Restoring Solution Only Packages (packages not installed within a project), is not supported in this iteration.

Validation:

  • Need to validate that this works with a CI machine running under SYSTEM or similar account. Look at how typical CI machines are setup.

Last edited Sep 26, 2011 at 9:27 PM by Haacked, version 8