Deploy ASP.NET MVC5 to Production Server(2008-2012)

Posted in Visual Studio, on 1/4/2015

This blog is for when you deploy ASP.NET MVC + nuget to windows server, you're getting error that can't load assemblies. For example, If you use ASP.NET's bundle feature, which is System.Web.Optimization. This blog might help your problem by change the project reference settng and basically you have to change the reference Copy Local as true.

Could not load file or assembly....

Long story is that after code your ASP.NET MVC(4 or 5) and everything works fine on your local machine or local IIS. You also use Nuget as package for your web application, so that duing build your solution visual studio will automatic get version from site or other nuget package provider. My point is everything work fine on your local, now you want to deploy to web server, assume window server.

So, most of the case working fine, but some time after your deployment error come out.

My problem is that, my web application use System.Web.Http, System.Web.Http.WebHost, System.Web.Optimization, Newtonsoft.Json. I noticed that I can't find any of these inside of my web server's. So, something wrong with my nuget, or I thought I'm not doing something correct.

Should I copy all the nuget package folder to the webserver? Whn I think about it, I just need all dlls to be inside the bin folder. Does nuget is possible to do that? I have not found out nuget could do this, but after nuget add project references, if the dll setting's copy to local is false then if you change to true the dll will copy to the bin folder during build.