Why Visual Studio 2010 publish website with source code?

萝らか妹 提交于 2019-12-22 04:41:01

问题


I'm using Visual Studio 2010 with the new website publish dialog. I have a Web Application website. When published, in theory it should compile all the code into an single assembly. However, in both Debug and Release, after publishing the directory always contains source code of page and user controls (even with the untransformed web.config files Web.Debug.config and Web.Release.Config). This is very confusing.

But with package/publish web project configuration and Generate Deploy package context menu item, the Package\PackageTmp directory is clean.

  • Why doesn't Visual Studio use this Package to publish the website?
  • Where is the precompile option?
  • Web.config xml transform seems not work, why does Visual Studio bring this feature to confuse me?

回答1:


The correct answer is to look in the Package/Publish Web settings (in the web application project properties) and look for the "Items to deploy".

For a web application you'd want "Items to deploy" to have "Only files needed to run this application" which would NOT copy the source code files, since they've been compiled into the DLL in the bin folder.

Note that this setting varies for your current Build type (Debug/Release/etc), so plan accordingly...

Ciao!




回答2:


You need to understand the differences between Web Application Projects versus Web Site Projects.

To deploy a Web application project, you copy the assembly that is created by compiling the project to an IIS server. In contrast, to deploy a Web site project, you typically copy the project source files to an IIS server.

For Web application projects, you typically build the project in Visual Studio or by using the ASP.NET batch compiler on a computer that is not the production IIS server. All code-behind class files and standalone class files in the project are compiled into a single assembly, which is then put in the Web application project's Bin folder. (The .aspx and .ascx files are compiled dynamically in a manner similar to what is done for Web site projects.)

For Web site projects, you do not have to manually compile the project. Web site projects are typically compiled dynamically by ASP.NET (on both the development computer and the production IIS server). You can choose between batch compilation mode, which typically produces one assembly per folder, and fixed compilation mode, which typically produces one assembly for each page or user control.




回答3:


In visual studio 2013/2015, select an option "Precompile during publishing"



来源:https://stackoverflow.com/questions/8632794/why-visual-studio-2010-publish-website-with-source-code

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!