Exclude files from web site publish in Visual Studio

后端 未结 11 1957
醉话见心
醉话见心 2020-11-27 12:44

Can I exclude a folder or files when I publish a web site in Visual Studio 2005? I have various resources that I want to keep at hand in the Solution Explorer, such as alte

11条回答
  •  臣服心动
    2020-11-27 13:09

    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:

     
      ... 
      File1.aspx;Folder2\File2.aspx 
      **\.svn\**\*.*
      Folder1;Folder2\Folder2a 
    
    

    Wildcards are supported.

    To explain the example above:

    • The 1st ExcludeFilesFromDeployment excludes File1.aspx (in root of project) and Folder2\File2.aspx (Folder2 is in the root of the project)
    • The 2nd ExcludeFilesFromDeployment excludes all files within any folder named .svn and any of its subfolders
    • The ExcludeFoldersFromDeployment excludes folders named Folder1 (in root of project) and Folder2\Folder2a (Folder2 is 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

提交回复
热议问题