{"id":4124,"date":"2008-10-04T21:17:22","date_gmt":"2008-10-04T21:17:22","guid":{"rendered":"https:\/\/blogs.msdn.microsoft.com\/webdev\/2008\/10\/04\/exclude-files-and-folders-from-wdp-output\/"},"modified":"2008-10-04T21:17:22","modified_gmt":"2008-10-04T21:17:22","slug":"exclude-files-and-folders-from-wdp-output","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/dotnet\/exclude-files-and-folders-from-wdp-output\/","title":{"rendered":"Exclude Files and Folders from WDP Output"},"content":{"rendered":"<p>Web&#160; Deployment Projects (WDP) allows you to pre-compile your web into binaries and further also allows you to merge the assemblies produced in the format that you like. In my earlier posts I had talked about various WDP features and the latest release of WDP for VS 2008.&#160; You can read more about this <a href=\"http:\/\/vishaljoshi.blogspot.com\/2008\/01\/visual-studio-2008-web-deployment.html\">here<\/a><\/p>\n<p>By default in the WDP output you will find project files (.csproj\/.vbproj), user files (.user), .PDB, obj folders and other artifacts which are not required for web to run.&#160; It is pretty easy to get rid of these files automatically by following these simple steps:<\/p>\n<p><strong>Step 1 &#8211; Open WDP project file for editing<\/strong><\/p>\n<p>Open WDP project file by right clicking on the WDP project and clicking &quot;Open Project File&quot; <\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/16\/2019\/02\/image_2.png\"><img decoding=\"async\" style=\"border-top-width: 0px;border-left-width: 0px;border-bottom-width: 0px;border-right-width: 0px\" height=\"275\" alt=\"image\" src=\"https:\/\/devblogs.microsoft.com\/dotnet\/wp-content\/uploads\/sites\/10\/2008\/10\/image_thumb.png\" width=\"322\" border=\"0\" \/><\/a> <\/p>\n<p><strong>Step 2 &#8211; Exclude .pdb, .user, .csproj\/.vbproj files from Build<\/strong><\/p>\n<p>In the ItemGroup section of WDP project which looks like below:<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/16\/2019\/02\/image_4.png\"><img decoding=\"async\" style=\"border-top-width: 0px;border-left-width: 0px;border-bottom-width: 0px;border-right-width: 0px\" height=\"41\" alt=\"image\" src=\"https:\/\/devblogs.microsoft.com\/dotnet\/wp-content\/uploads\/sites\/10\/2008\/10\/image_thumb_1.png\" width=\"125\" border=\"0\" \/><\/a> <\/p>\n<p>Add the files which you would like to exclude from the SourceWebPhysicalPath like below<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/16\/2019\/02\/image_6.png\"><img decoding=\"async\" style=\"border-top-width: 0px;border-left-width: 0px;border-bottom-width: 0px;border-right-width: 0px\" height=\"75\" alt=\"image\" src=\"https:\/\/devblogs.microsoft.com\/dotnet\/wp-content\/uploads\/sites\/10\/2008\/10\/image_thumb_2.png\" width=\"413\" border=\"0\" \/><\/a> <\/p>\n<p>ExcludeFromBuild will allow you to remove these files even though they are present as part of the parent project.&#160; After this step your item group should look as below:<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/16\/2019\/02\/image_8.png\"><img decoding=\"async\" style=\"border-top-width: 0px;border-left-width: 0px;border-bottom-width: 0px;border-right-width: 0px\" height=\"94\" alt=\"image\" src=\"https:\/\/devblogs.microsoft.com\/dotnet\/wp-content\/uploads\/sites\/10\/2008\/10\/image_thumb_3.png\" width=\"459\" border=\"0\" \/><\/a> <\/p>\n<p>In the similar fashion above you can remove other items which you do not need in the output<\/p>\n<p><strong>Step 3 &#8211; Removing items after Build<\/strong><\/p>\n<p>As you know folders like OBJ are produced during build process hence if you do not want them to appear in the output then they need to be removed after build.&#160; to do this we need to add one more item to the above ItemGroup as below<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/16\/2019\/02\/image_10.png\"><img decoding=\"async\" style=\"border-top-width: 0px;border-left-width: 0px;border-bottom-width: 0px;border-right-width: 0px\" height=\"107\" alt=\"image\" src=\"https:\/\/devblogs.microsoft.com\/dotnet\/wp-content\/uploads\/sites\/10\/2008\/10\/image_thumb_4.png\" width=\"488\" border=\"0\" \/><\/a> <\/p>\n<p>Do note that this time we are using the property $(OutputPath) instead of the property $(SourceWebPhysicalPath)<\/p>\n<p>Now the last step is actually use the itemgroup value as part of the AfterBuild target.&#160; Your WDP project file by default has these commented section as shown below<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/16\/2019\/02\/image_12.png\"><img decoding=\"async\" style=\"border-top-width: 0px;border-left-width: 0px;border-bottom-width: 0px;border-right-width: 0px\" height=\"161\" alt=\"image\" src=\"https:\/\/devblogs.microsoft.com\/dotnet\/wp-content\/uploads\/sites\/10\/2008\/10\/image_thumb_5.png\" width=\"586\" border=\"0\" \/><\/a> <\/p>\n<p>We need to uncomment the call to Target &quot;AfterBuild&quot; and call &quot;RemoveDir&quot; on the OBJ folder Item we declared in the ItemGroup above&#8230; This can be done as shown below:<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/16\/2019\/02\/image_14.png\"><img decoding=\"async\" style=\"border-top-width: 0px;border-left-width: 0px;border-bottom-width: 0px;border-right-width: 0px\" height=\"79\" alt=\"image\" src=\"https:\/\/devblogs.microsoft.com\/dotnet\/wp-content\/uploads\/sites\/10\/2008\/10\/image_thumb_6.png\" width=\"387\" border=\"0\" \/><\/a> <\/p>\n<p>Finally at the end your WDP project file will look as below:<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/16\/2019\/02\/image_16.png\"><img decoding=\"async\" style=\"border-top-width: 0px;border-left-width: 0px;border-bottom-width: 0px;border-right-width: 0px\" height=\"320\" alt=\"image\" src=\"https:\/\/devblogs.microsoft.com\/dotnet\/wp-content\/uploads\/sites\/10\/2008\/10\/image_thumb_7.png\" width=\"685\" border=\"0\" \/><\/a> <\/p>\n<p><strong>Step 4 &#8211; Save WDP project file, and Rebuild WDP<\/strong><\/p>\n<p>After the above changes to the WDP project file when you rebuild your WDP project you should have your output folder without PDB, Project file, user file or OBJ folder in it.<\/p>\n<p>Vishal R. Joshi | Program Manager | Visual Studio Web Developer<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Web&#160; Deployment Projects (WDP) allows you to pre-compile your web into binaries and further also allows you to merge the assemblies produced in the format that you like. In my earlier posts I had talked about various WDP features and the latest release of WDP for VS 2008.&#160; You can read more about this here [&hellip;]<\/p>\n","protected":false},"author":404,"featured_media":58792,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[197],"tags":[31,7273,7263,7284,147,7302,7316,7292,7285,7268],"class_list":["post-4124","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-aspnet","tag-asp-net","tag-orcas","tag-pm","tag-vishal-r-joshi","tag-visual-studio","tag-visual-studio-2008","tag-visual-studio-2008-sp1","tag-vs2008","tag-wdp","tag-web"],"acf":[],"blog_post_summary":"<p>Web&#160; Deployment Projects (WDP) allows you to pre-compile your web into binaries and further also allows you to merge the assemblies produced in the format that you like. In my earlier posts I had talked about various WDP features and the latest release of WDP for VS 2008.&#160; You can read more about this here [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/posts\/4124","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/users\/404"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/comments?post=4124"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/posts\/4124\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/media\/58792"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/media?parent=4124"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/categories?post=4124"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/tags?post=4124"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}