Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Web Application won't publish without .cs files

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.

like image 576
Rafe Avatar asked May 15 '14 19:05

Rafe


2 Answers

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

like image 156
BenCr Avatar answered Oct 21 '22 04:10

BenCr


Turns out that I added this line to my csproj file earlier when I was trying to get my project to build on our build server. Removing it fixed the problem:

<Target Name="GatherAllFilesToPublish"></Target>
like image 30
Rafe Avatar answered Oct 21 '22 06:10

Rafe