Compile ASCX files during deployment instead of first boot?

When I deploy an ASP.NET project to a server that contains many ASCX files, loading the first page may take some time because the ASCX files are compiling. However, only those that are actually on the page are compiled, so part of my deployment process is to go to a bunch of pages on the site. After all the pages have been moved, the site runs smoothly.

I would prefer ASP.NET to collect all of these ASCX files immediately upon deployment in order to remove this inaccurate deployment step.

What is the best way to do this?

+5
source share
3 answers

, ASP.NET Precompilation:

-, . , , , . , - .

, - . (, ) Bin. , , . , , Bin.

+4

- ASP.net "-", . - " -"

- ASP.NET - ASP.NET

+2

You can run msbuild in your web solution and it will compile your code, then you can expand the markup by compiled .dll.

Sample NAnt script for this:

<target name="determineMsbuildPath">
    <readregistry property="net.bin" key="SOFTWARE\Microsoft\MSBuild\ToolsVersions\4.0\MSBuildToolsPath"/>
</target>

<target name="msbuild" depends="determineMsbuildPath>
    <exec basedir="${net.bin}\" program="MSBuild.exe">
        <arg value="${solution}"/> <!-- put the path to your web solution here -->
        <arg value="/p:OutputPath=${workdir}"/>
    </exec>
</target>
0
source

All Articles