TFS build not restoring/finding some nuget packages?

Apparently, when you’re using some shared project with Nuget packages, it is possible that TFS build will throw some errors at you saying that he can’t find all/some of the packages.
(When inspecting the build logs, you will see the warning MSB3245 “Could not resolve this reference”.

When adding packages to a project, the csproj file will get a hint path to the (then) current location of the package. However, when you then reference this project in another solution, it will start looking for these packages in the first solution’s packages directory.
During TFS Build, your first solution may not (yet) be build, causing this error.

This can be fixed in a couple of ways, e.g.
– You can have TFS first build the first solution, and afterwards your other solution. This way the packages will be restored to where they should be.
– But a more elegant solution is changing the hint paths to use $(SolutionDir)\packages instead. This way, your build should always work, regardless of the order in which your solutions are being build.

LEAVE A COMMENT