[RESOLVED]Publish of MVC app includes ".compiled" files in bin.

When I first started using ASP.Net using 1.1 we were using web apps.  We discovered that once we deployed a web app, as long as we were making a change to the code behind we only had to redploy the dll and if we made a change to the front end of a page we
only had to redploy the dll and that one page.  Then in ASP.Net 2.0 web apps were gone and we only had websites.  I discovered that when you published a website, that if you made a change of even one letter to the code behind, you had to redploy the entire
web site.  Then they brought back web apps and it once again reverted to only the need to redeploy the assembly.

I have been publishing test copies of my MVC app to the test server for the past several weeks without really looking at what was happening ( I was just automatically republishing and redeploying the entire project because there were always significant changes
to both the views and the controllers.  Just last friday I realized I had an error in my JQuery on one of my views so I went to the cshtml file in the published version to make that correction, (since it was so minor).   At that time I discovered that publishing
an mvc app converts the cshtml files into placeholder files with nothing on them.  I then realized that the cs part of the cshtml would require that it be included in the assembly.  This has me thinking well then there is no need to replace all of the project
files each time I do a publish, I only need recompile the prject and copy over the assembly, (plus any JavaScript files that might have been changed).  However, when i went to copy the assembly I found that instead of being only one assembly for the project,
there were a number of files in the bin with extensions of cshtml.soemhexadecial.compiled .  This reminded me of the contents of the published website files that had to be included with the publishing of a 2.0 web site.  I found out the hard way in 2.0 that
all of the new files of the published project had to be included when doing a new publish.

So My question:  Do you have to recopy all of the bin files each time you republish an MVC web app?  Is there some way to only deploy the project assembly?

By default, if you keep to one project, your class files (controllers and model) will be compiled to one dll named after the project. Your view files (.cshtml) are not precompiled when you build the site. If you make a change to a controller or model file,
you need to rebuild and copy the new dll to the site’s bin folder. If you make a change to a view file, you can just ftp the altered cshtml file and it will be compiled on demand just like a Web Site project.

That is the case on a build.  But on a publish that is not the case.  We do not put files with source code onto our servers.  The apps must be published before being deployed.  Which is why using 2.0 web sites was such a major ordeal, and web apps were such
a convenience.

Hi joeller,

About web application projects versus web site projects, please refer to:

# Web Application Projects versus Web Site Projects in Visual Studio


You said that there are .compiled files in bin folder after publish. The reason is that you checked Precompile during publishing option and uncheck the Allow precompiled site to be updatable, please check it.

# Advanced Precompile Settings Dialog Box


Best Regards


Leave a Reply