NuGet References not resolved in TeamCity
I have set up a TeamCity build for my Visual Studio solution and I have configured NuGet Automatic Package Restore on the build server. I have also checked in the NuGet.config file in the .nuget folder at the root of my solution directory.
In addition, I have even tried setting up NuGet Installer build steps before my solution runs/builds in order to restore all of the necessary NuGet packages, however, I am still getting this error message when I attempt to autobuild in TeamCity:
RepositoryBase.cs(6, 7): error CS0246: The type or namespace name 'Dapper' could not be found (are you missing a using directive or an assembly reference?)
This does not occur when I build locally in Visual Studio, but only occurs when I am running my build through TeamCity.
Is there any configuration that I need to change either in my solution configuration or in TeamCity in order to get my solution files to successfully build in TeamCity?
Please advise.
Please sign in to leave a comment.
Hi Samir,
Please try to build your solution on problematic build agent manually via command line using msbuild.exe (without TeamCity). Does it work?
Also please check that referenced assembly actually exists on a disk.
I dug into this problem, as I was having the same. The assembly does show on the disk, in the packages folder. It seems the Visual Studio 2017 runner does not use the same flags when it runs CSC.exe to compile. It's actually not generating /reference parameters for the packageReference elements in the .csproj folders. When Visual Studio is generating the flags, its using a reference to my global nuget cache not the packages folder. I'll open a ticket to have it reviewed.