Visual Studio 2010: How to exclude folder/files from “Build Deployment Package”?

前端 未结 2 1099
悲&欢浪女
悲&欢浪女 2021-01-12 04:47

Is it possible to exclude specific files or folders from \"Build Deployment Package\" function in VS 2010?

In VS 2008 it was possible with Web Deployment package, un

相关标签:
2条回答
  • 2021-01-12 05:21

    I need to exclude some files also, I want to remove assemblies .xml files from the deploy (I don't need them on the server), I couldn't find anything on the web so I decide to look for it on my own.

    After digging into the msbuild of the MsPublish I found it, you need to setup the following in your project (edit manualy the .csproj):

    <ItemGroup>
      <!-- This will exclude the .xml files from the bin folder -->    
      <ExcludeFromPackageFiles Include="$(OutputPath)*.xml" />  
    
      <!-- This will exclude the tmp folder from the bin folder -->    
      <ExcludeFromPackageFolders  Include="$(OutputPath)tmp" />  
    </ItemGroup>
    
    0 讨论(0)
  • 2021-01-12 05:35

    just to clarify the ItemGroup include should be after after the following import in your .csproj:

    <Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets" />
    

    eg.

    <ItemGroup>
      <ExcludeFromPackageFiles Include="Sample.Debug.xml">
        <FromTarget>Project</FromTarget>
      </ExcludeFromPackageFiles>
    </ItemGroup>
    

    Sayed Ibrahim Hashimi has a good post on this: http://sedodream.com/2010/05/01/WebDeploymentToolMSDeployBuildPackageIncludingExtraFilesOrExcludingSpecificFiles.aspx

    0 讨论(0)
提交回复
热议问题