4

I'm trying to setup a build for a .Net MVC project in TeamCity. I followed the steps described here: How to build ASPNET applications in TeamCity

But the build is still failing. The error messages I have are

App_Start\BundleConfig.cs(2, 18): error CS0234: The type or namespace name 'Optimization' does 

not exist in the namespace 'System.Web' (are you missing an assembly reference?) 
App_Start\FilterConfig.cs(2, 18): error CS0234: The type or namespace name 'Mvc' does not exist in the namespace 'System.Web' (are you missing an assembly reference?) 
App_Start\RouteConfig.cs(5, 18): error CS0234: The type or namespace name 'Mvc' does not exist in the namespace 'System.Web' (are you missing an assembly reference?) 
Controllers\HomeController.cs(5, 18): error CS0234: The type or namespace name 'Mvc' does not exist in the namespace 'System.Web' (are you missing an assembly reference?) 
Controllers\HomeController.cs(9, 35): error CS0246: The type or namespace name 'Controller' could not be found (are you missing a using directive or an assembly reference?) 
Global.asax.cs(5, 18): error CS0234: The type or namespace name 'Mvc' does not exist in the namespace 'System.Web' (are you missing an assembly reference?) 
Global.asax.cs(6, 18): error CS0234: The type or namespace name 'Optimization' does not exist in the namespace 'System.Web' (are you missing an assembly reference?) 
App_Start\BundleConfig.cs(9, 44): error CS0246: The type or namespace name 'BundleCollection' could not be found (are you missing a using directive or an assembly reference?) 
App_Start\FilterConfig.cs(8, 50): error CS0246: The type or namespace name 'GlobalFilterCollection' could not be found (are you missing a using directive or an assembly reference?) 
Controllers\HomeController.cs(11, 16): error CS0246: The type or namespace name 'ActionResult' could not be found (are you missing a using directive or an assembly reference?) 
Controllers\HomeController.cs(16, 16): error CS0246: The type or namespace name 'ActionResult' could not be found (are you missing a using directive or an assembly reference?) 
Controllers\HomeController.cs(23, 16): error CS0246: The type or namespace name 'ActionResult' could not be found (are you missing a using directive or an assembly reference?) 

I have all the references with Copy Local = true and True in the csproj. TeamCity is downloading correctly the nuget packages but it seems that is not using them. All I can see is that in the .csprojResolveAssemblyReference file in obj/Release there is the following line:

C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETFramework\v4.5.1\System.Web.dll

So, it seems that is using that file and not the file in the nuget folder.

What do I have to do to have the build up and running?

Thank you very much.

vgaltes
  • 1,150
  • 11
  • 18
  • I have this exact same problem, but with TFS instead of TeamCity, so I'd be interested in seeing what the possible solution is to this. – Brendan Green Nov 27 '14 at 01:23

3 Answers3

3

You need to add a step to your build process to restore all NuGet packages. See here for instructions.

Shaul Behr
  • 36,951
  • 69
  • 249
  • 387
1

System.Web.Optimization namespace is not in the System.Web.dll assembly. It's got its own assembly, System.Web.Optimization.dll. Add that DLL as a reference. If you don't have that DLL, get it via NuGet. I think this is the correct package.

mason
  • 31,774
  • 10
  • 77
  • 121
  • I have System.Web.Mvc and System.Web.Optimiztion referenced via NuGet, and TeamCity is dowloading both packages. I don't understand why it doesn't look for them in the packages folder. – vgaltes Nov 27 '14 at 09:27
  • Try copying the DLL's manually to the bin folder. I've had it fail to do it automatically before. – mason Nov 27 '14 at 13:43
  • No luck. I think I'm going to re-install the machine and try again. – vgaltes Dec 01 '14 at 21:19
0

I've finally solved the problem. What I did is to upload the NuGet packages to the source code repository and remove the NuGet step in the TeamCity configuration. Actually, I prefer this option to be able to work in my code although NuGet was down.

Thank you very much.

vgaltes
  • 1,150
  • 11
  • 18