Why Visual Studio 2010 publish website with source code?

Roc Ho picture Roc Ho · Dec 26, 2011 · Viewed 11k times · Source

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?

Answer

enorl76 picture enorl76 · Feb 5, 2012

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".

enter image description here

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!