dotnet / msbuild

The Microsoft Build Engine (MSBuild) is the build platform for .NET and Visual Studio.
https://docs.microsoft.com/visualstudio/msbuild/msbuild
MIT License
5.23k stars 1.35k forks source link

Exclude patterns don't work when Include uses a recursive glob on OS X #970

Closed rainersigwald closed 8 years ago

rainersigwald commented 8 years ago
  <ItemGroup>
    <ProjectWithoutConfiguration Include="bin/**/*proj" Exclude="bin\Bootstrap\testpackage.nuproj;src\**" />
  </ItemGroup>

  <Target Name="BuildAndTest">
    <Message Text="Items: @(Projectwithoutconfiguration) " Importance="High" />
  </Target>

from the root of the MSBuild repo emits a list that contains testpackage.nuproj. If the Include pattern is bin/Bootstrap/*proj or bin/Bootstrap/**/*proj, the Exclude works as expected, so the critical piece seems to be that there is a recursive ** glob and that it gets expanded during the consideration of include.

Possibly a regression from lazy evaluation?

rainersigwald commented 8 years ago

cc @brthor: the only workaround I can see right now is to not use a recursive glob.

brthor commented 8 years ago

@rainersigwald

I appreciate the workaround, but it is simply not possible for migration unless we evaluate the glob at migration time, in which case we are not really doing a true migration of the project.

For the moment this will just remain a bug for migrated apps on OSX. We can direct users to clean before building to prevent inadvertent includes.

cdmihai commented 8 years ago

It is most likely the optimization of not exploding globs twice via the new feature in FileMatcher to accept globs to ignore.

Before this, it worked because both include and exclude would explode globs, and those exploded strings would match just because they were produced by the same code.

Now, the FileMatcher does a few string comparisons to reason whether to visit certain files or directories. All those string equality checks need to be probably replaced with more intelligent comparers that reason about different directory separators, os based case sensitivity, trailing slashes, etc

cdmihai commented 8 years ago

978 appears to have fixed this issue. I tried reproing it on osx but the recursive excludes / includes worked fine (tests also confirm this). Only caveat for now is that excludes work with backslashes only.