Feryt
Feryt

Reputation: 2302

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

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, unfortunately this project is not available in VS2010.

Upvotes: 8

Views: 6841

Answers (2)

Justin Moore
Justin Moore

Reputation: 827

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

Upvotes: 1

Shay Erlichmen
Shay Erlichmen

Reputation: 31928

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>

Upvotes: 9

Related Questions