开发者

ASP.NET: The file name generation rule for pre-compiled files

After pre-compiled a ASP.NET web site, I got many files with the names like

App_Web_accountbalance.aspx.dfa151d5.dll

Do you know the rule for the random chars (开发者_JAVA技巧in bold) above?

Can we fix the random chars?

The reason to fix it is that if we modify AccountBalance.aspx file later and re-compile the web site, can we just replace App_Web_accountbalance.aspx.dfa151d5.dll.

Thank you.


The characters are not random, but more in line with hashing. The purpose is to make the file name unique in the bin folder. Although not advisable, you can replace just certain files to update your website. If you modify AccountBalance.aspx and recompile, you need to replace App_Web_accountbalance.aspx.dfa151d5.dll, accountbalance.aspx.dfa151d5.compiled, and other assemblies and files that your aspx file depends.

I derived the answer from my experience. I was not looking for the file naming rule, but a way to deploy just the assembly of a changed page, same reason as the original post.

The setup:

A web application, deployed non-updateable (updatable=”false” in PrecompileApp.config), pre-compiled assemblies with no fixed names

What I did:

  • Make the change to the page (say, a.aspx) in development (Visual Studio 2010)
  • Publish the site with fixed naming to local drive (Build > Publish Web Site, check the box: Use fixed naming and single page assemblies)
  • Go to the bin folder of the local publish site and look for a.aspx.xxx.compiled
  • Open the file with Notepad and note any dependency (say, b.aspx, c.master)
  • Copy all the affected assemblies and the .compiled files to the bin folder in production server. In this example, they are:
    • a.aspx.xxx.compiled
    • b.aspx.xxx.compiled
    • c.master.xxx.compiled
    • App_Web_a.aspx.xxx.dll
    • App_Web_b.aspx.xxx.dll
    • App_Web_c.master.xxx.dll

If you want to know my story, the change was due to a change in a factor in a calculation. The customer knew of the change much earlier, but did not let us know until it became urgent. A proper deployment would involve other parties and much coordination, and would be too late. Plus, I only had the source code of two versions back, and requesting the latest would take time. So, a hot fix on just that calculation change was required as a temporary measure.


1) you can generate single assembly per web application if you want. So when you make a change in web application, you only need to deploy just one dll.

for this, you can check option "Use fixed naming and single page assemblies"

2) Reference from MSDN Article: "The assembly names are generated automatically by the compiler and it is therefore not obvious which assemblies map to which source files. The compiler also creates new names each time it runs, so that the names of assemblies might not be the same after each compilation. In addition, if source files have changed, the compiler might batch up source files differently, meaning that the resulting assemblies do not necessarily represent the same source files. If you are maintaining a deployed Web site and want to update only the assemblies for recent changes, the output from batch compilation can make that job more complicated.

To help you in this situation, aspnet_compiler.exe supports an option specifically designed for packaging and release management: the -fixednames option. This option enables you to create compiler output that has two benefits. The first is that the assemblies produced by the compiler have the same names each time you compile. The second is that the assemblies are based on the same input files each time."

http://msdn.microsoft.com/en-us/library/aa479044.aspx

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜