7

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?
ssube
  • 47,010
  • 7
  • 103
  • 140
Roc Ho
  • 317
  • 1
  • 3
  • 11
  • Is it a web application or a web site? Do you see only `.as?x` files or also `.cs` files? – SLaks Dec 26 '11 at 03:56
  • @SLaks I'm sure it's Web Application not Web site.I already solved,just because I set `Include all project files` in `Package/Publish web` configuration – Roc Ho Dec 26 '11 at 11:56
  • hi @RocHo me too have the same problem but the thing is i am publishing the WEBSITE and not the webapplication in VS2013 Professional Edition. When i publish it also publish the SOURCE CODE and not jst the binaries/dll. So, will u please suggest me any solution to publish files in .aspx/.dll files only? – SHEKHAR SHETE Feb 27 '15 at 06:11

3 Answers3

11

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!

enorl76
  • 2,562
  • 1
  • 25
  • 38
  • hi @enorl76 please suggest me any solution for the above comment? help appreciated! I tried your solution but unfortunately unable to locate this option in VS 2013 professional edition. :( – SHEKHAR SHETE Feb 27 '15 at 06:12
  • @SHEKHARSHETE i have VS 2013, and I just looked and its the same. Perhaps you are trying to use a different project type? You have to be using a Web Application project type. – enorl76 May 10 '16 at 14:18
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.

JonnyBoats
  • 5,177
  • 1
  • 36
  • 60
0

In visual studio 2013/2015, select an option "Precompile during publishing" enter image description here

OrganicCoder
  • 107
  • 1
  • 4