I am trying to get an MVC solution to build on a test server without having visual studio or MVC 4 installed on the machine.
The solution refers to all the required MVC assemblies as nuget packages. In the projects all of the MVC assemblies are marked as copy local. Of course, on my dev machine the solution builds fine in visual studio.
On the build machine I have installed the .net sdk and I am trying to use MSBuild to build the solution. All of the nuget packages are under source control and when I do an SVN update on the server it gets all of the packages.
When I run the build I am getting a broken reference to the MVC DLLs. I don’t get why this is happening since in the solution the DLLs are referenced and are present for the build to use.
Here is a sample of the error returned by 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?) ...
I have spend hours on this. It frustrates me that it builds in visual studio on my machine but not on the server using msbuild.
Seth
“Copy local” just means it’ll copy the assemblies from your MVC3 installation which you haven’t installed on your remote machine.
Did you try to copy the MVC dlls to a folder (which you commit to your VCS repository) in your project and reference all of them from there instead from the default installation directory?? That should work just fine.