Web Application won't publish without .cs files

不羁岁月 提交于 2019-12-21 10:47:13

问题


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.


回答1:


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.




回答2:


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>


来源:https://stackoverflow.com/questions/23686946/web-application-wont-publish-without-cs-files

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