views:

685

answers:

5

Is it possible to exclude a folder in a web project from being published? We've got some documentation and scripts that included in a particular project folder, and are added to the project, but when I do a VS publish, I don't want them to go up to the production server.

I know they shouldn't be in the project, but I thought I'd find a workaround before I try to convince the owner to modify the way he's doing things.

A: 

Can you not exclude them from the project through visual studio to stop them being published. They will the still exist in the filesystem

Dean
A: 

The only way that you can do this to my knowledge would be to exclude it from the project, do the publish, then re-include it in the project. That can be an issue.

Mitchel Sellers
A: 

For the files you don't want to go, loop at the properties and set the 'Copy to Output Directory' to 'Do not copy'

This option is not available for directories, however.

MStodd
+2  A: 

This doesn't answer your question, exactly, but my feeling is that unless you are a single developer publishing to a server, you would be better off doing builds on a dedicated workstation or server using MSBuild (or some other building and deploying solution) directly (and thereby would be able to very granularly control what goes up to production). MSBuild can not only build, but using some extensions (including open source types), it can also deploy. Microsoft has a product called MSDeploy in beta, and that might be an even better choice, but having no experience with it, I cannot say for certain.

In our situation, we have a virtual workstation as a build box, and all we have to do is double click on the batch file that starts up an MSBuild project. It labels all code using VSS, gets latest version, builds the solution, and then deploys it to both servers. We deploy exactly what we want to deploy and nothing more. We're quite happy with it.

The only downside, if it could be considered a downside, is that at least one of us had to learn how to use MSBuild. VS itself uses MSBuild.

Cyberherbalist
This makes sense. I was hoping for something like a Right-Click, "Don't deploy this folder", but I figured we'd need something more structured. Deployment to an FTP server through Visual Studio is like pulling teeth anyway, so we're better off with this route.
rwmnau
A: 

There are probably much better ways to solve this problem but when we publish a build for our dev servers, we'll run a batch file when the build is complete to remove the un-needed folders and web.configs (so we don't override the ones that are already deployed).

dkpatt