开发者

MSBuild exclude/include order [closed]

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center. Closed 11 years ago.

I have a task where I select some files, based on extension, but want some folders not being processed. The problem is that seems that the Exclude filter is applied before the Include one so at the end all the files are included.

This is where I select the files:

<CreateItem Exclude="**\.svn\**;
  $(MSBuildProjectDirectory)\obj\**;
  $(MSBuildProjectDirectory)\bin\**;
  $(MSBuildProjectDirectory)\My Project\*.*;
  $(MSBuildProjectDirectory)\Properties\*.*;
  $(MSBuildProjectDirectory)\Dependencies\*.*;
  $(MSBuildProjectDirectory)\Installation\**;
  $(MSBuildProjectDirectory)\Extenders\**\*.*"
Include="$(MSBuildProjectDirectory)\**\*.ascx;
  $(MSBuildProjectDirectory)\**\*.aspx;
  $(MSBuildProjectDirectory)\**\*.css;
  $(MSBuildProjectDirectory)\**\*.xml;
  $(MSBuildProjectDirectory)\**\*.xslt;
  $(MSBuildProjectDirectory)\**\*.js;
  $(MSBuildProjectDirectory)\**\*.resx;
  $(MSBuildProjectDirectory)\**\*.rpt;
  $开发者_开发知识库(MSBuildProjectDirectory)\**\*.gif;
  $(MSBuildProjectDirectory)\**\*.jpg;
  $(MSBuildProjectDirectory)\**\*.png;"

>

In this case if any of the "Exclude" folders include any file whose extension matches the "Include" list, it will still be included in the final list.

So the question is how can I force that all files from the excluded folders are in fact exclude.

EDIT: seems there was another problem in the MsBuild file that caused this to fail. It's working as expected.


On MSDN you can read that CreateItem task is deprecated. It is suggested to use ItemGroup, because since .net 3.5 you can embed it in targets. In your case, if you want to be sure exclude is run after include, you can write:

<ItemGroup>
  <YourItemName Include="$(MSBuildProjectDirectory)\**\*.ascx;$(MSBuildProjectDirectory)\**\*.aspx;$(MSBuildProjectDirectory)\**\*.css;$(MSBuildProjectDirectory)\**\*.xml;$(MSBuildProjectDirectory)\**\*.xslt;$(MSBuildProjectDirectory)\**\*.js;$(MSBuildProjectDirectory)\**\*.resx;$(MSBuildProjectDirectory)\**\*.rpt;$(MSBuildProjectDirectory)\**\*.gif;$(MSBuildProjectDirectory)\**\*.jpg;$(MSBuildProjectDirectory)\**\*.png;" Exclude="**\.svn\**;$(MSBuildProjectDirectory)\obj\**;$(MSBuildProjectDirectory)\bin\**;$(MSBuildProjectDirectory)\My Project\*.*;$(MSBuildProjectDirectory)\Properties\*.*;$(MSBuildProjectDirectory)\Dependencies\*.*;$(MSBuildProjectDirectory)\Installation\**;$(MSBuildProjectDirectory)\Extenders\**\*.*"/>
</ItemGroup>

I know you already sorted it out, but I'm posting it in case someone else got similar problem. ItemGroup is much more helpful if you want to include data from more than one source and in many places in your code.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜