Visual Studio 2010:如何从“构建部署包”中排除文件夹/文件?

时间:2010-02-26 10:47:52

标签: visual-studio-2010

是否可以从VS 2010中的“构建部署包”功能中排除特定文件或文件夹?

在VS 2008中,可以使用Web部署程序包,遗憾的是,该项目在VS2010中不可用。

2 个答案:

答案 0 :(得分:9)

我还需要排除一些文件,我想从部署中删除程序集.xml文件(我在服务器上不需要它们),我在网上找不到任何东西所以我决定寻找它靠我自己。

在深入了解MsPublish的msbuild后,我找到了它,你需要在你的项目中设置以下内容(编辑.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>

答案 1 :(得分:1)

只是为了澄清ItemGroup包含应该在之后 在.csproj中导入以下内容之后:

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

例如

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

Sayed Ibrahim Hashimi有一个很好的帖子:http://sedodream.com/2010/05/01/WebDeploymentToolMSDeployBuildPackageIncludingExtraFilesOrExcludingSpecificFiles.aspx