Your official information source from the .NET Web Development and Tools group at Microsoft.
Web Deployment (see this posting for an overview) offers a set of pre-determined options to allow users to include the most common sets of files for deployment. These options are as follows and can be found under the “Items to deploy” section on the Package / Publish Web property page.
Excluding Specific Files / Folders If these pre-determined options do not provide the exclusions required and you desire the flexibility to exclude specific files and/or folders while at the same time leaving them in your actual project, you can directly edit the web application’s project file to accomplish your goal.
Here are the steps to follow in order to exclude specific file(s) and/or folder(s) from packaging and/or publishing:
Project File excerpt containing an example excluding the specific files, File1.aspx and File2.aspx, as well as the specific folders, Folder1 and Folder2, from deploying with the Debug configuration: <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> ... <OutputPath>bin\</OutputPath> <NoWarn>42016,41999,42017,42018,42019,42032,42036,42020,42021,42022</NoWarn> <ExcludeFilesFromDeployment>File1.aspx;File2.aspx</ExcludeFilesFromDeployment> <ExcludeFoldersFromDeployment>Folder1;Folder2</ExcludeFoldersFromDeployment> </PropertyGroup> Note: As packaging and publishing are configuration aware, these elements can be included in any custom configuration defined within the project file (not just the debug configuration), thereby making it possible to use the same base project while choosing to exclude different sets of files or folders from publishing (or packaging) under different custom configurations. File Variation: Excluding a file under a folder (rather than at the root of the web application). For example, if File2.aspx in the sample above was under a folder named FileSamples; the <ExcludeFilesFromDeployment> element would look like this: <ExcludeFilesFromDeployment>File1.aspx;FileSamples\File2.aspx</ExcludeFilesFromDeployment> Folder Variation: Excluding a folder under another folder (rather than at the root of the web application). For example, if Folder1 in the sample above was under a folder named FolderCollection; the <ExcludeFoldersFromDeployment> element would look like this: <ExcludeFoldersFromDeployment>FolderCollection\Folder1</ExcludeFoldersFromDeployment>
Project File excerpt containing an example excluding the specific files, File1.aspx and File2.aspx, as well as the specific folders, Folder1 and Folder2, from deploying with the Debug configuration:
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> ... <OutputPath>bin\</OutputPath> <NoWarn>42016,41999,42017,42018,42019,42032,42036,42020,42021,42022</NoWarn> <ExcludeFilesFromDeployment>File1.aspx;File2.aspx</ExcludeFilesFromDeployment> <ExcludeFoldersFromDeployment>Folder1;Folder2</ExcludeFoldersFromDeployment> </PropertyGroup>
Note: As packaging and publishing are configuration aware, these elements can be included in any custom configuration defined within the project file (not just the debug configuration), thereby making it possible to use the same base project while choosing to exclude different sets of files or folders from publishing (or packaging) under different custom configurations.
File Variation: Excluding a file under a folder (rather than at the root of the web application). For example, if File2.aspx in the sample above was under a folder named FileSamples; the <ExcludeFilesFromDeployment> element would look like this: <ExcludeFilesFromDeployment>File1.aspx;FileSamples\File2.aspx</ExcludeFilesFromDeployment>
Folder Variation: Excluding a folder under another folder (rather than at the root of the web application). For example, if Folder1 in the sample above was under a folder named FolderCollection; the <ExcludeFoldersFromDeployment> element would look like this: <ExcludeFoldersFromDeployment>FolderCollection\Folder1</ExcludeFoldersFromDeployment>
You will see that the files and/or folders you included within the <Exclude…> elements are not in your package (if that is what you chose to do) or at you publishing destination.
Hope this helps and happy web deploying, Nichole Baker | Visual Web Developer
Is it possible to use MSBuild wildcards? For example:
<ExcludeFilesFromDeployment>**\.svn\**\*.*</ExcludeFilesFromDeployment>
I guess I could have tried it before asking. They do work.
Hi, i have a deployment question. In a solution with 4 projects, how do I create a package that puts the contents of 3 projects under 1 project but inside a folder. For example:
Project 1Contents
L Modules Folder
L Project 2 Contents
L Project 3 Contents
L Project 4 Contents
Everytime i fire a build, all project contents appear at the same level
Hope you can help.
Thanks!