Reputation: 6790
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
Upvotes: 3
Views: 4335
Reputation: 3851
Try running nuget install on the solution prior to running your msbuild command? If you are running VS2010 or later and have updated the nuget extension to the latest version, there is an option on the Project menu to "Enable Nuget Package Restore." This will configure your solution and project files to that they run nuget install as part of the build process.
Upvotes: 0
Reputation: 84784
Right click on the project and click "Unload" and then again and click "Edit".
Find the <Reference>
for System.Web.Mvc
. If the <HintPath>
doesn't refer to the "packages" directory (or is missing), then that's your problem. Just remove the package and all references and start again.
NuGet package restore only restores the files on disk, it doesn't update the project references.
Upvotes: 5
Reputation: 32920
"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.
Upvotes: 1