Exclude files and folders by adding ExcludeFilesFromDeployment and ExcludeFoldersFromDeployment elements to your project file (.csproj, .vbproj, etc). You will need to edit the file in a text editor, or in Visual Studio by unloading the project and then editing it.
Add the tags anywhere within the appropriate PropertyGroup (Debug, Release, etc) as shown below:
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
...
<ExcludeFilesFromDeployment>File1.aspx;Folder2\File2.aspx</ExcludeFilesFromDeployment>
<ExcludeFilesFromDeployment>**\.svn\**\*.*</ExcludeFilesFromDeployment>
<ExcludeFoldersFromDeployment>Folder1;Folder2\Folder2a</ExcludeFoldersFromDeployment>
</PropertyGroup>
Wildcards are supported.
To explain the example above:
- The 1st
ExcludeFilesFromDeploymentexcludesFile1.aspx(in root of project) andFolder2\File2.aspx(Folder2is in the root of the project) - The 2nd
ExcludeFilesFromDeploymentexcludes all files within any folder named.svnand any of its subfolders - The
ExcludeFoldersFromDeploymentexcludes folders namedFolder1(in root of project) andFolder2\Folder2a(Folder2is in the root of the project)
For more info see MSDN blog post Web Deployment: Excluding Files and Folders via the Web Application’s Project File