Web Deployment Project builds files that are no longer part of the project - asp.net

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.

Related

How do I get all dll files within the bin folder to build successfully onto another server via TFS?

I have just started using the Build functionality within TFS and I can't see all my dlls being uploaded to the server. I have tried looking online but have failed to find a solution.
So there is a specific dll that has been added to the bin folder in a ASP.NET application and has been referenced and checked in. After I 'Queue New Build' within Team Explorer, it completes successfully.
So when I run the website on the server, it complains that it can't find that dll. And when I access the server and look into IIS Manager, I can see that the dll I have added is not located in the bin folder.
How do I get this to appear there via TFS build?
I solved the problem by these steps:
Adding the dll file to the bin folder locally.
When viewing the dll in Solution Explorer, second click it and then select Include in Project (this is what I never did).
Second click the References folder and browse to the dll in the bin folder. (not sure if this part was essential, but I did it anyway).
Make sure it builds.
Check into TFS.
View Team Explorer > Builds
Second click the build you want to run, and select Queue New Build, then Queue.
After running successfully, I checked the the _PublishedWebsites folder to see if the bin was included. It was. And then I ran the website on the server and WALLA! It worked.

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.
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>

What is the purpose of Binaries\_PublishedWebsites directory under TFS build

TFS generates a publish directory under the build agent working directory:
Z:\TFSBuilds\1\box\CT\Binaries\\_PublishedWebsites
I am supposing that this is where TFS is automatically publishing the site. How can I use it for auto publishing of sites... as Should we refer our IIS website to this directory. What is the purpose of it?
Firstly, the working directory is as the name says, a "working" directory. That is where the build agent downloads the source, perform compiles etc. It also clears the working directory whenever you run the build again so you risk grabbing unfinished artifacts when you try to retrieve from the working directory.
TFS defines a "drop folder" that it will copy the final artifacts to, once the build completes. You can define the drop folder for a build by editing it's build definition:
Right click on the build and choose 'edit build definition.
Select the 'Build Defaults' section.
Tick 'This build copies output files to a drop folder'
Enter an UNC path for the build agent to copy artifacts to (make sure the Build Agent has access to that UNC path!)
Secondly, in regard to _PublishedWebsites. The build agent will create a _PublishedWebsites folder for each Web project it builds as part of its build artifacts (so if you tell it to build a solution with 2 web projects, it'll create [Project name A]\_PublishedWebsites and [Project Name B]\_PublishedWebsites). Inside each _PublishedWebsites folder are the contents to be dropped into an IIS application, same as what you would get by right clicking on a web project and selecting 'Publish'. I normally add a last step in the build workflow to copy the contents of this _PublishedWebsites folder to my desired IIS directory.
This link tells you how to add the copy workflow: TFS 2010: Copy _PublishedWebsites to test server
And here's more on drop folders: http://msdn.microsoft.com/en-us/library/bb778394.aspx

Making a build that removes source CS files

How to make a build in VS 2010 within an ASP.NET MVC application that would remove all of the source code (CS and VB) files? When I build a website or web app I usually copy the contents of the entire solution to the hosting server. Mostly clients get the source but sometimes I do not want to expose the source to the hosting server thus only the Public (or Content) folder, views, masters and the built DLL should be copied.
Manual solutions are not applicable. What do you guys use?
Click Publish from the Build menu, then select File System and deploy into a folder. The contents of that folder should have all the stuff you want and nothing more.
You can add del commands to the post-build script. (Perhaps wrapped up in a batch file)
You can even write a C# program that deletes the files, then run that in the post-build script.

How can I exclude a folder from a .NET installer for a website?

We have an installer for a website of ours which works great, I exclude the web.config and a few other files when creating the installer. However I can't seem to exclude a folder. Is this possible?
I've created the installer using the .NET built in Web Setup Project found in the visual studio group Other project types > Setup and Deployment within the new project dialog. This only has the option of including groups of output and excluding files via the filter.
What technology are you using to generate your installer?
Edit after additional info in the question: OK, I haven't worked with the built in Web Setup Project, but I did use a regular setup project once. You control the output of each project that's included in the setup by setting the Build Action property of each content file. Set it to None to exclude a file.
There isn't a Build Action property for a folder, so you'll have to set it for all the files within a folder. If a folder doesn't have any content files, then it shouldn't be included in your setup project.
The only way I found to exclude entire folders and any files within sub-directories was to modify the deployment project which fed into my Installer. Check out the following for information removing folders pre-build:
http://www.meadow.se/wordpress/?p=137
And this for post-build:
http://blogs.msdn.com/webdevtools/archive/2008/10/05/exclude-files-and-folders-from-wdp-output.aspx

Resources