NuGet package restore used to be MSBuild-based and you would enable it by selecting
Enable NuGet Package Restore in Visual Studio. Nowadays, it is recommended that you don't use this approach, but instead just set the option in Visual Studio to
Allow NuGet to download missing packages. This works really well in Visual Studio, but when you select the Visual Studio build runner in TeamCity it does not go ahead and restore all the NuGet packages for you in the same way, so you get a compilation error. Instead, you have to explicitly create a separate step to run before the Visual Studio build step.
To enable NuGet Package Restore with TeamCity you need to add a build step before the Visual Studio solution build with a runner type of
The first time you create this installer, there might not be a NuGet.exe to choose. Just select the NuGet Settings option and you are presented with the option to download the latest version. Select Fetch NuGet and you are able to select a NuGet.exe version to be downloaded for use by TeamCity.
Once you have selected the NuGet.exe you just have to provide the path to your Visual Studio solution file, which you can do with the useful file tree (pictured):
I can recommend some great resources on using TeamCity for continuous integration/delivery from my fellow TestStackers:
In additiona, JetBrains also has a blog post that goes into more detail about the NuGet Installer build runner.