Reputation: 689
I added to my solution via Nuget the Autoumapper and NUnit packages and they work great and the project compiles in my computer.
When i declared the build server to build this solution i got this messages:
[MSBuild] AutoMapper\AutoMapperSpike.csproj: Build default targets (1s)
[10:35:50][AutoMapper\AutoMapperSpike.csproj] ResolveAssemblyReferences
[10:35:50][ResolveAssemblyReferences] ResolveAssemblyReference
[10:35:50][ResolveAssemblyReference] Primary reference "AutoMapper".
[10:35:50][ResolveAssemblyReference] C:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets(1360, 9): warning MSB3245: Could not resolve this reference. Could not locate the assembly "AutoMapper". Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors.
[10:35:50][ResolveAssemblyReference] For SearchPath "{HintPathFromItem}".
[10:35:50][ResolveAssemblyReference] Considered "..\packages\AutoMapper.2.2.1\lib\net40\AutoMapper.dll", but it didn't exist.
Does anyone know how to solve this problem?
Another thing i noticed is that it creates artificts in build server also with the packages folder. The only thing it can`t do is build the project in the build server.
Upvotes: 7
Views: 8908
Reputation: 1274
Make sure TeamCity actually downloads the package. You can see that in the build history on a single build result page, on the NuGet Packages tab. If you see your package there, then TeamCity is okay with the package.
Next, make sure you can build your project fresh out of the VCS, i.e. take a clean clone and try to build it as such, as that is what TC has to do.
My problem in a very similar scenario was that I had just copied one project into anothers repository and the references where wrong, though the compilation succeeded locally due to cached DLL:s. Uninstalling the package and installing it again from the Visual Studio Package Manager resolved the issue.
Upvotes: 4
Reputation: 2326
In a Visual Studio environment, there’s an option in the UI that sets a value on your user profile so you never have to remember it again. On a build server, though, there’s no such option. Instead, you have to set the environment variable “EnableNuGetPackageRestore” to “true” as part of your build.
I would recommend against trying to set the environment variable inside your build scripts or .csproj files. Here’s the blog article all about why it happened and what to set on your dev machine/build server.
Upvotes: 6
Reputation: 174457
You need to either check in the packages into your VCS or - better - enable NuGet package restore in your solution.
Upvotes: 0