Web Application won't publish without .cs files

Rafe picture Rafe · May 15, 2014 · Viewed 8.9k times · Source

I have an asp.net web application project that I am publishing via Build > Publish within visual studio 2013. I am publishing to the file system, using the precompile option selected. My project has "Only files needed to run this application" selected in the Package/Publish Web settings screen. However, regardless of what I do, the .cs files (code-behind) and designer.cs files get copied to the output folder during publishing.

This project was created by using the File > New Project > ASP.NET Web Application functionality in visual studio. Then files from a website project were added to the application, and the "convert to web application" command was run on it from the build menu. The conversion to a web app seems to have worked fine, but I am unable to publish without the .cs files being included.

What else needs to be done in order to get a web application to publish without the code-behind files included? Any ideas on what I can look into?

Could there be a setting at the solution level that is causing this? The new web application was added to a pre-existing solution with about a dozen other projects.

Another thing to note is that when I create a new web app with visual studio in a new project, and publish w/ the same settings, it does NOT include the .cs files.

I've also tried deleting and then creating a new publish profile.

Answer

BenCr picture BenCr · Sep 16, 2014

I just fixed this by deleting my old publish profile and creating a new one.

The new one appeared to have all the same settings as the old one but when I published it didn't copy the .cs files.

Edit: This answer is a lie. There was a difference between the two profiles. The new profile was in Release configuration.

Edit 2: There's a setting in the project settings which determines what gets published. Select "only files needed to run this application" from the following page.

Publish Settings Page