我试图在没有在机器上安装visual studio或MVC 4的情况下,在测试服务器上构建MVC解决方案 .
该解决方案将所有必需的MVC程序集称为nuget包 . 在项目中,所有MVC程序集都标记为本地副本 . 当然,在我的开发机上,该解决方案在visual studio中构建得很好 .
在构建机器上我安装了.net sdk,我正在尝试使用MSBuild来构建解决方案 . 所有的nuget包都在源代码管理下,当我在服务器上进行SVN更新时,它会获得所有的包 .
当我运行构建时,我得到了对MVC DLL的破坏引用 . 我不明白为什么会发生这种情况,因为在解决方案中引用了DLL并且存在供构建使用 .
以下是MSBuild返回的错误示例...
DataAnnotations\RunDataAnnotationsFromModelPropertyAttribute.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?)
DataAnnotations\RunDataAnnotationsFromModelPropertyAttribute.cs(12,93): error CS0246: The type or namespace name 'IClientValidatable' could not be found (are you missing a using directive or an assembly reference?)
Security\MyAuthenticateAttribute.cs(6,18): error CS0234: The type or namespace name 'Mvc' does not exist in the namespace 'System.Web' (are you missing an assembly reference?)
Security\MyAuthenticateAttribute.cs(12,48): error CS0246: The type or namespace name 'AuthorizeAttribute' could not be found (are you missing a using directive or an assembly reference?)
Security\MyAuthorizeAttribute.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?)
Security\MyAuthorizeAttribute.cs(13,45): error CS0246: The type or namespace name 'AuthorizeAttribute' could not be found (are you missing a using directive or an assembly reference?)
Web\Mvc\MyLoginController.cs(7,18): error CS0234: The type or namespace name 'Mvc' does not exist in the namespace 'System.Web' (are you missing an assembly reference?)
Web\Mvc\MyLoginController.cs(44,62): error CS0234: The type or namespace name 'Mvc' does not exist in the namespace 'System.Web' (are you missing an assembly reference?) ...
我花了好几个小时 . 令我感到沮丧的是,它在我的机器上构建了visual studio,而不是在使用msbuild的服务器上构建 .
赛斯
3 回答
“复制本地”只是意味着它将从您未安装在远程计算机上的MVC3安装中复制程序集 .
您是否尝试将MVC dll复制到项目中的文件夹(您提交到VCS存储库)并从那里引用所有这些文件而不是默认安装目录?这应该工作得很好 .
右键单击项目并单击“卸载”,然后再次单击“编辑” .
找到
<Reference>
forSystem.Web.Mvc
. 如果<HintPath>
不是你的问题 . 只需删除包和所有引用,然后重新开始 .NuGet包还原仅还原磁盘上的文件,它不会更新项目引用 .
在运行msbuild命令之前尝试在解决方案上运行nuget install?如果您正在运行VS2010或更高版本并且已将nuget扩展更新为最新版本,则“项目”菜单上有一个“启用Nuget包还原”选项 . 这会将您的解决方案和项目文件配置为在构建过程中运行nuget install .