3

I am trying to use ASP.NET precompile tool aspnet_compiler.exe to compile site after it has been deployed.

As per book definition running in-place precompile on web machine should improve first page load experience. The compilation tool compiles each ASP.NET page, storing the compiled version in the %WINDIR%\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files folder just like if the pages had each been visited for the first time from a browser. In-place precompilation can speed up the first request made to newly deployed ASP.NET pages on your site because it alleviates the runtime from needing to perform this step.

For some reason for me it does not work expected described way.

When running aspnet_compiler.exe locally on Web machine manually:

C:\Windows\Microsoft.NET\Framework\v4.0.30319\aspnet_compiler.exe -v /7.1 -p C:\MyPathToWebSite\www

It created folder of following structure structure:

C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\7.1\640c1f87\4be3507b

When I try to hit web page using browser, ASP.NET creates another cached version in the following folder on same server:

C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\7.1\bc8a1bb3\42b014d4

As you can see precompile works in both scenarios (manual and IIS), but for somehow IIS does not see that pages already precompiled and cashed and trying to re-compile everything again. I could not figure out what is missing or done wrong, since aspnet_compiler.exe has limited parameter options for in-place compilation.

So far, I have tried following during testing/investigation in regards of Temporary ASP.NET cache:

  • Seems like it’s not user related, does not matter what user is running manually
  • Not related on Source/Target IP, since same folders are created on different servers in different subnets

Any ideas and help appreciated.

Black Frog
  • 11,595
  • 1
  • 35
  • 66
Alex
  • 31
  • 4

2 Answers2

4

I faced the same issue. Only using metabase path to my site solved it.

aspnet_compiler.exe -m /LM/W3SVC/[site ID]/root
-1

The files you see in the first folder were not jitted. You only compile your site to MSIL, and when you first access some page it gets compiled to native image code - these are the files you see in the second folder. You might want to use Ngen - http://msdn.microsoft.com/en-us/library/6t9t5wcf(v=vs.110).aspx

Shay___
  • 163
  • 9
  • Thanks for replying. In this case this defeat the purpose/goal of the pre-compiler, which suppose to create native code. Specifically when you run in place compilation on the machine itself? – Alex May 21 '14 at 13:39
  • Compilation doesn't necessarily mean the code is compiled to native code. In .NET (and java, for example) there are two stages of compilation - the first is from source-code to MSIL, and the second is from MSIL to native. Pre-compilation refers only to the first stage, while Ngen compiles your source-code directly to native (I'm not too familiar with Ngen, but I guess there are some levels of compilation). – Shay___ May 21 '14 at 17:12