开发者

Is there a way to stop VS2008 Web Deployment Project from creating Source folder when using ExcludeFromBuild?

开发者 https://www.devze.com 2023-02-17 10:47 出处:网络
When excluding files in Web Deployment Project using ExcludeFromBuild e.g. <ItemGroup> <ExcludeFro开发者_JS百科mBuild Include=\"$(SourceWebPhysicalPath)\\**\\*.csproj*\"/>

When excluding files in Web Deployment Project using ExcludeFromBuild e.g.

  <ItemGroup>
      <ExcludeFro开发者_JS百科mBuild Include="$(SourceWebPhysicalPath)\**\*.csproj*"/>
  </ItemGroup>

I end up with a Source folder containing all next to the Release and Debug folders. This folder does not show up if I don't use any ExcludeFromBuild option.

Is there a way to stop this folder from being created? Why is it created in the first place?


In Misrosoft.WebDeployments.targets file (which web deployment project file imports) there's a _CopyBeforeBuild target which copies all the source files when ExcludeFromBuild property isn't empty or EnableCopyBeforeBuild is specified:

...

<CopyBeforeBuildTargetPath>$(MSBuildProjectDirectory)\Source</CopyBeforeBuildTargetPath>

...

<Target Name="_CopyBeforeBuild" Condition=" '$(EnableCopyBeforeBuild)' == 'true' or '@(ExcludeFromBuild)' != ''  ">
    ...
    <RemoveDir Directories="$(CopyBeforeBuildTargetPath)"/>
    <MakeDir Directories="$(CopyBeforeBuildTargetPath)"/>
    <Copy SourceFiles="@(_WebFiles)" DestinationFolder="$(CopyBeforeBuildTargetPath)\%(_WebFiles.SubFolder)%(_WebFiles.RecursiveDir)" />
    ...
</Target>

So the script creates the source directory and doesn't remove it. That directory annoys me too so I add next lines to web deployment project file:

<Target Name="AfterBuild">
    <RemoveDir Directories="$(CopyBeforeBuildTargetPath)" />
</Target>
0

精彩评论

暂无评论...
验证码 换一张
取 消