這裡介紹兩種發布方式
1:使用開發工具中的CopySite功能。
其實他還是一個XCopy,就是多了 同步檔案/串連網站 等功能。還是把所有原始碼一起發布了
2:使用先行編譯部署
這一個就走向另外一個極端:發布的時候只有dll檔案,沒有任何原始碼,甚至是html代碼也沒有。
使用方式:開啟asp.net2.0的sdk的Command Prompt或者找到windows/miscorsoft.net/framework/v2.0/目錄下,開始運行aspnet_compiler.exe。這個程式就可以進行先行編譯。aspnet_compiler.exe -?可以顯示出這個命令的協助。
介紹一種格式:aspnet_compiler -v /<websitename> -p <source> <destination>
比如:aspnet_compiler -v /form.ui.web -p c:\websites\form.ui.web c:\websites\deployment 該命令把虛擬目錄名字叫做form.ui.web位於c:\websites\form.ui.web 目錄下的程式先行編譯到c:\websites\deployment 目錄下。
編譯之後:
1:所有的.aspx頁面成了這種東西:
This is a marker file generated by the precompilation tool, and should not be deleted!
這個檔案的作用只是標記它存在,通過IIS可以訪問到,僅此而已,其內容已經全部被編譯到dll中,bin目錄下有一個default.aspx.cdcab7d2.compiled檔案存在
2:所有的ascx控制項“消失”了,同時在Bin裡面,多出來好多.compiled檔案,其中一個檔案內容如下:
<preserve resultType="3" virtualPath="/form.ui.web/configFiles/IPS/InformationCreate.ascx" hash="bdca4e266" filehash="1879aaf63513" flags="10000" assembly="App_Web_x_lehwbd" type="ASP.InformationCreate_ascx">
<filedeps>
<filedep name="/form.ui.web/configFiles/IPS/InformationCreate.ascx" />
</filedeps>
</preserve>
也就是說在執行的時候,會根據這裡的聲明,從程式集裡面讀取這個檔案。
一開始還擔心我裡面的調用ascx的代碼會出錯,因為我都是Control.Load(path); 萬一沒有了ascx檔案,豈不是Load不到了? 看來是杞人憂天了,沒有一點問題。
3:資源檔和以前差不多,被編譯到bin目錄下的若干個子目錄下,比如zn-ch什麼的。
4:global、masterpage和theme檔案也是類似的,出現了App_global.asax.compiled、default01.master.28fa1680.compiled、Theme_DefaultTheme.compiled等檔案