21

I know I can just copy all of my files from my development environment into my live website directory, but then I know I'm copying several files that aren't necessary (e.g. the .sln file and .csproj files).

What files actually have to be copied for ASP.NET MVC web applications to run? (E.g. Do I need to copy all .CS files?)

1
  • Just Publish it to a local folder and copy all the contents to your server.
    – SepehrM
    Jul 13, 2014 at 15:17

4 Answers 4

32

If you develop in Microsoft Visual Studio, you can use the Build > Publish option (when you're in the context of an ASP.NET MVC project) and publish it directly.

If you cannot use this and have to do a copy all you need is anything that ISN'T a .cs file (views, .config files etc) and your compiled ASP.NET MVC site's .dll (ex MvcApplication1.dll). If you want to get an idea of what you need use the Build > Publish tool to a local directory and take a look at what's in there.

You don't need solution or project files.

2
  • Excellent answer. This also caught some errors, e.g. some images files that I had in the project but weren't in the correct folder.
    – dlchambers
    Jan 6, 2016 at 13:13
  • good idea. i used this so i could know which files I should ask Jenkins to copy to my live server
    – Andy
    May 11, 2017 at 15:27
4

Using the Build / Publish approach is the best to ensure you have the files you need. Before building though, if you don't have ASP.NET 3.5 SP1 installed on your server, make sure you go into the references in your project for the following assemblies and set the to "Copy Local" in each of their respective property pages.

System.Web.MVC System.Web.Routing System.Web.Abstractions

This will make sure that each of these assemblies is copied to your "bin" folder on the published site.

Brian

3

After you compile your project, you shouldn't copy all .cs files.

Take a look at this link.

0

Basically everything but the views get compiled into a dll. You can use the deploy option to see what you need to deploy ;).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.