1
votes

I am trying to create a build definition to build solution using VS 2015 build definition in Team City. However when my build configuration runs it gives me the following error

C:\TeamCity\buildAgent\work\e6cc09e5f0da4a07\packages\Microsoft.Net.Compilers.1.0.0\tools\Microsoft.CSharp.Core.targets(67, 5): error MSB4062: The "Microsoft.CodeAnalysis.BuildTasks.Csc" task could not be loaded from the assembly C:\TeamCity\buildAgent\work\e6cc09e5f0da4a07\packages\Microsoft.Net.Compilers.1.0.0\build..\tools\Microsoft.Build.Tasks.CodeAnalysis.dll. Could not load file or assembly 'file:///C:\TeamCity\buildAgent\work\e6cc09e5f0da4a07\packages\Microsoft.Net.Compilers.1.0.0\tools\Microsoft.Build.Tasks.CodeAnalysis.dll' or one of its dependencies. The system cannot find the file specified. Confirm that the declaration is correct, that the assembly and all its dependencies are available, and that the task contains a public class that implements Microsoft.Build.Framework.ITask.

It seems to me that I am missing some dlls but the machine on which I have setup Team City for testing is also my Dev machine so by right I have everything installed and the solution is building fine.

Can you please guide me as to what might be wrong here?

2
The missing files look to be NuGet dependencies judging by their paths. If so, have you configured automatic package restore and if so which method are you using? docs.nuget.org/consume/package-restorePaul Hunt

2 Answers

1
votes

I dont know whether you have moved on from this issue or not, but if someone is still getting this issue.
As Paul Hunt mentioned, this issue is happening because of nuget packages are not able to restore.
To solve this quickly on your machine just copy everything from your solution's "packages" folder to the TeamCity's buildAgent\work[project] folder.
This issue will disappear.

0
votes

I was facing the same issue but after using NuGet Installer as a build step my all problems gets resolved.

Just you need to do one thing, before going to build your project - Just add one build step and select Runner type as NuGet Installer

You can check from this screenshots:

enter image description here

You can add this for any project. Let me know if this solution works for you or not.