Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

mvc which files are needed for deployment?

I've been working with webforms and recently started to work with mvc. With webforms, when we use to push to the qa/prod server, we alway copied over the files. leaving behind the .cs files, so just the .aspx, bin folder, along with associated js/css files would go.

with mvc, if we are copying the directory over from our pc (where we develop), what files are needed, do we need the .cshtml files for example? I just want to avoid having to push all the files if they are not needed.

like image 614
Paritosh Avatar asked May 06 '14 17:05

Paritosh


2 Answers

They are definitely not all required. What you are going to want to do is setup a way to publish, this ranges from doing a "bin deploy" to feeding in ftp settings and using a "single click deploy" approach.

What it all boils down to though is this. You will need

  • A bin folder with every relevant .dll
  • A content folder with relevant images and css files
  • A script folder with relevant .js scripts
  • A views folder with nested folders for views with relevant .cshtml files
  • A .webconfig file in the views folder and also one at the very root
  • The packages.xml file at the very root
  • The global.asax file with markup pointing to the application starting in global.asax.cs

What this excludes is every single .cs file. These will all be composed into your projects .dll. So if you are developing FunWebApp, then all your c# will be rolled into FunWebApp.dll in your bin folder.

like image 64
Travis J Avatar answered Oct 04 '22 19:10

Travis J


Use the Visual studio "Publish" option available on your UI Project. This will generates all the required files you neeeds includes, bin folder, Views folder(which will have the .cshtml files),Content folder,Script folder, Config file(web.config) etc.

Right click on your project and select "Publish". You will be shown a wizard where you can define what kind of publish you want. You have different options like FTP, File system etc.

enter image description here

You will not see the Controllers folder / Other class files because code inside that folder is compiled to your assembly which is in the Bin folder

like image 34
Shyju Avatar answered Oct 04 '22 18:10

Shyju