I'm doing exactly this and there is not anything really specific to TFS when it comes to leveraging NuGet packages in the build process.
When you run the power command Enable-PackageRestore, it does three things:
- Creates a .nuget folder containing nuget.exe.
- Adds build targets udner .nuget\ for calling nuget.exe in (1) to install and/or update packages.
- Includes the targets in (2) in your project file(s) (.csproj).
(1) makes sure that even if a computer does not have NuGet installed the packages can be installed and updated. This makes it ideal for build agents since you minimize the configuration load for new agents.
The targets in (2) hooks into the build process of the project and installs and / or updates packages before any compilation takes place. It is defined to take the packages.config located directly under each project's folder.
Basically what you need to make sure this works when building with TFS is that the .nuget folder needs to be checked in. Remember that when adding files .exe files are ignored by default. Just erase that ignore filter in the Add Files dialog and you're all
But, in your case it gets a little bit more complicated, since you are hosting your own NuGet feed. You need to specify what sources you want NuGet to use. There are two ways to do this:
- You can add your feed to %APPDATA%\NuGet\NuGet.Config on your build agent.
The problem with this is that it adds another configuration management for build agents. Personally I like to keep my build agents as clean as possible to make it easy to add new agents.
- So I would suggest opening the NuGet.settings.targets file in the .nuget folder and changing the package sources via the tag <PackageSources>.
Hope this helps!