Web Application won't publish without .cs files - asp.net

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.

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.

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>

Related

"Swap out" VS projects in solution maintaining source control

I have a solution with several projects. One of these projects is a "Web Site" I need to convert into a "Web App", following the steps outlined at http://msdn.microsoft.com/en-us/library/aa983476(v=vs.100).aspx
Those steps create the web app as a new project, instead of replacing the old one. Now that I have the Web App working, I need to replace the old one, but I don't want to lose the version control or other TFS things.
So far, I've tried simply replacing the files in the Site project's folder with the files from the App project's folder, but Visual Studio still sees it as a Site. So I edited the .sln file to point to the .csproj, but VS tells me the project "needs to be migrated" (and if I try to do that, it fails).
Deleting project and adding a new one won't lose the version control. When you select Show Deleted Items, you still can view the history of the deleted Web Site project:

Just publish modified controllers, models and some parts of a ASP.NET MVC project

If I change my views (.cshtml) or styles (.css) or scripts (.js) in my MVC projects then I can publish it easily by right click on it and select Publish FILE_NAME
If I changed some controllers files or BLL classes or infrastructure classes,
Which files should be published? which DLLs?
Of course added references must be published but what are another?
Should I publish all the DLL files in the bin folder or just some?
Is there an easy way to VS detect modified files and publish theme by a command or...?
Edit1
I use FTP method to direct publish and upload our site to the server.
My Publish Preview Step Snapshot:
What is the name of DLL files that contains the compiled information of controllers, BLL classes and...?
I just published the MVC5Bootstrap-3-1-1-Less.dll and it worked!
So if we uploaded a website and then want only publish the new modified controllers or classes of the MVC web application (here: MVC5) to the server, we should upload the following files:
MVC5Bootstrap-3-1-1-Less.dll after build
Added references to the bin folder after build
Here is a image of how publish DLLs of bin folder from Visual Studio:
The publish wizard on the project (right click on project > Publish...) should automatically determine which files have changed and need to be updated, and show you what files will be updated.
After clicking Start Preview:

How to add project (.sln) into existing asp.net website files

I have tried almost all methods to make new project using exisiting files of asp.net in vs 2010 but i failed to run on new machine.
each time i did this it shows error that "could not load project from d:\path name" etc etc that is my last computer path name
Now what i am looking for , i have a website and all asp.net pages but i am unable to see its working by single click on project exe .
please help me out that how i can make project using existing asp.net files
remember : i have only asp.net pages to laod directly into visual studio but i want project exe so when i click on .sln file i can see site working.
In order for it to work you need to keep in mind you have to use original source code and not pre-compiled code from the server. To import your old files into a .sln file:
Create a New Website/Web Application
Add Existing Item Select item(s)
that you are trying to import into this new solution.
Make sure you dont add any .vbproj or .sln files from the previous project.

ASP.NET Without Project File

I've got a ASP.NET project without the .proj file. How do I recreate the project file, so I can work on it on my machine?
Is this possbile?
Are you sure it's not a Web Site Project, as opposed to a Web Application Project? Web Site projects do not have project files - you open a folder rather than a project file. See here for the differences between the two.
To check, each page of a Web Application project will have a .aspx, a .aspx.cs and a .aspx.designer.cs, whereas the Web Site project pages don't have the designer files.
You can create a new project and then you can use the "Add Existing Item" and add each of your files (you can select multiple files).
EDIT:
Or your can drag and drop the files into the "Solution Explorer"
First of all, you need to run VS2005 SP1 or later. In VS2005, they removed the project file. They reintroduced it again in SP1.
If you don't have a project file, your project is called a "Web Site". If you have a project file, it's a "Web Application". One difference between the two is also that in a web application, you compile all code-behind files to a single .dll. In a web site, each code behind file goes in its own dll (or are compiled dynamically at runtime)
I believe that if you right click the project in solution explorer, there is a "Convert To Web Application" menu item.
Note, you must rename the App_Code folder to something else, otherwise it will be compiled both at compile time, and at runtime.
Personally I much prefer web applications to web sites

Web Deployment Project builds files that are no longer part of the project

This is the error I get:
Error 101 Could not load type
'control'. /Test.vbproj/x.ascx 1 1
WebDeployProject
This is a left over file that was part of the project last week, but one of the developers deleted it from the project. I have to manually delete the file in order to get the WDP to build. Is there a way to tell the WDP to ignore the files that are not part of the project or to see that these files are not part of the project and delete them?
You'll need to use your source control tools to find and remove local files that aren't under source control.
For instance, if you're using TFS, do the following:
Open Source Control Explorer (View -> Other Windows -> Source Control Explorer)
Right-click on the path in TFS that corresponds to your local working copy and select Compare
Use your TFS path as Source Path and your local working copy as Target Path
Under View Options, select "Show items that exist only in target path"
You've now got a list of all the files that exist in your local working copy but aren't in source control. For each file, either delete your local copy or add it to source control.
It could have something do to with the type of web project is it.
If it's a web site, then the compiler will attempt to compile every file in the folder. However, if it's a Web Application Project, then it will only compile those that you've specifically added as part of the project.
If you have recently deleted/removed a file from your project then you need go to Project > "Show all files" and all removed files will apear in your solution explorer. You can delete the file, /x.ascx and rebuild your WDP.
It has nothing to do with the type of Web project: http://amiraryani.wordpress.com/2008/11/06/web-deployment-project-aspparse-could-not-load-type/.
A Web Site itself considers files under its root directory as part of the site.
A Web Application Project itself allows you to customize build actions, etc. on a per-file basis.
A Web Deployment Project, however, will try to include files under the root directory (a la a Web Site), even if the WDP is associated with a WAP. That's why it doesn't matter which kind of Web project it is.
EDIT: To clarify, it would matter what type of Web project you are using if you were trying to Build, Debug, or Publish that project itself instead of using a WDP.

Resources