我正在尝试在 TeamCity 中为 .Net MVC 项目设置构建。我按照此处描述的步骤操作:How to build ASPNET applications in TeamCity
但是构建仍然失败。我收到的错误消息是
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?)
我在 csproj 中拥有 Copy Local = true 和 True 的所有引用。 TeamCity 正在正确下载 nuget 包,但似乎没有使用它们。我所能看到的是,在 obj/Release 的 .csprojResolveAssemblyReference 文件中,有以下行:
C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETFramework\v4.5.1\System.Web.dll
因此,似乎正在使用该文件,而不是 nuget 文件夹中的文件。
我需要做什么才能构建并运行?
非常感谢。
最佳答案
您需要在构建过程中添加一个步骤来恢复所有 NuGet 包。 请参阅here获取说明。
关于asp.net - 无法在 TeamCity 中构建 .Net MVC 项目,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27161006/