views:

163

answers:

2

Hi, I believe you can pre compile a asp.net mvc application but there are some issues with aspx files. Is it correct to say the view folder needs to be copied to the deployed location? If so does anyone know why? Thanks

+1  A: 

I've always used Web Deployment Projects to precompile web applications and prepare them for deployment. Scott Guthrie has blogged about it.

Darin Dimitrov
I know precompile works for aspx files in web deployment projects but I an talking about asp.net mvc applications
Noel
Well, they are nothing more than ASP.NET web projects.
Darin Dimitrov
Thanks Darin. I had read somewhere (cant find) that the aspx files in the view folder need to be copied as part of a deploy i.e they are not part of the precompiled dll. I cannot verify as I do not has IIS installed. Is this incorrect so?
Noel
Regardless of what compilation model you use, the markup portion of all ASP.NET pages (aspx) need to be copied to the production environment.
Darin Dimitrov
@Daring: I believe you're wrong. Precompiled aspx files are only placeholders, they're totally empty.
graffic
A: 

The short answer is that ASPX (and ASCX) files don't get compiled and must be copied with your application when you deploy to IIS.

You can precompile an ASP.NET MVC application, but the ASPX/ASCX files don't get included in the mix. In our experience, we weren't able to use aspnet_compiler.exe to bundle everything into a binary, so we use csc (via nant) to compile all of the stuff that can be compiled, and then copy the rest. This includes the View folder.

If it helps, the relevant portion of one of our nant scripts is as follows:

(Assuming all dependencies have already been copied to the site folder's (BuildDir in this case) bin folder)

<csc target="library" output="${BuildDir}/bin/${FinalDeployDllName}.dll" >
  <references failonempty="true">
    <include name="${BuildDir}/bin/SomeDependency.dll" />
  </references>
  <sources>
    <include name="${BuildDir}/**/*.cs" />
  </sources>
</csc>

<copy todir="${target}" overwrite="true">
  <fileset basedir="${BuildDir}">
    <include name="**/*.???x" />
    <include name="**/*.js" />
    <include name="**/*.jpg" />
    <include name="**/*.jpeg" />        
    <include name="**/*.gif" />
    <include name="**/*.png" />
    <include name="**/*.html" />
    <include name="**/*.css" />
    <include name="**/*.swf" />
    <include name="**/*.Master" />
    <include name="**/Web.config" />
    <include name="images/**/*" />
    <include name="bin/**/*" />
    <include name="Content/**/*" />
  </fileset>
</copy>

<delete>
  <fileset>
    <include name="${target}/*.build" />
    <include name="${target}/*.scc" />
    <include name="${target}/*.sln" />
    <include name="${target}/*.suo" />
    <include name="${target}/build.*" />
    <include name="${target}/*.resharper" />
    <include name="${target}/*.resharper.user" />
    <include name="${target}/bin/*.xml" />
    <include name="${target}/bin/*.pdb" />
  </fileset>
</delete>

This'll create a folder at {target} with all the required files for deployment, to be packaged from there as you see fit.

jasondoucette
Thanks for confirming this Jason.
Noel