问题
I'm using a Web Deployment Project 2008 to build my web application. I'd like to exclude the contents of several folders from the build but keep the blank directory itself. However, if I do this
<ExcludeFromBuild Include="$(SourceWebPhysicalPath)\ImageCache\**\*.*" />
it will exclude the ImageCache directory itself. So how do I keep the directory? Thanks in advance?
回答1:
I'm afraid you must do this in two lines :
<ExcludeFromBuild Include="$(SourceWebPhysicalPath)\ImageCache\**\*.*" />
<IncludeFromBuild Include="$(SourceWebPhysicalPath)\ImageCache\" />
But that could not work because The "Copy" task does not support copying directories
.
Thus, what I suggest is that you exclude the files like you did and create an empty directory in the AfterMerge target :
<ItemGroup>
<ExcludeFromBuild Include="$(SourceWebPhysicalPath)\ImageCache\**\*.*" />
<ItemGroup>
<...>
<Target Name="AfterMerge">
<MakeDir Directories="$(SourceWebPhysicalPath)\ImageCache" />
</Target>
来源:https://stackoverflow.com/questions/3804383/how-do-i-exclude-the-contents-of-a-directory-but-not-the-directory-itself-in-msb