2

Closed

Incorrect match of <file src="..\**" exclude="**\mask">

description

Algorithm for matching excluded files does not work correctly when "src" path points outside of current directory.

The following definition will not exclude the desired file:
<file src="..\Another**" exclude="\exclude.me" target="Content\Another" />

The workaround is to incude "..\" in the exclude match:
<file src="..\Another*
" exclude="..*
\exclude.me" target="Content\Workaround" />

If the proper fix is too difficult, then the user should be at least informed, that the exclude pattern will not work (i.e. if src starts with "..\" and exclude mask starts with "**" then report a warning or an error).

I have attached a simple case for reproducing the bug.

file attachments

Closed Aug 1, 2013 at 11:34 PM by deepakverma
tried and it excludes it now with the fix.

comments

dotnetjunky wrote Jan 22, 2013 at 5:36 PM

We will accept pull request for this bug.

MiroslavBajtos wrote Jan 27, 2013 at 2:30 PM

Apparently the problem is in construction of regex for matching files to exclude, see PackageBuilder.AddFiles() and PackageBuilder.ExcludeFiles().
basePath = "c:\bug\Folder"
source = "..\Another\**"
exclude = "**\exclude.me"

normalizedExludeWildcard = "c:\bug\Folder\**\exclude.me"
I am proposing to modify implementation of PathResolver.NormalizeWildcard() so that it ignores basePath for wildcards starting with two asterisks, i.e. the normalizedExludeWildcard will be "*\exclude.me"

I have also considered modifying PackageBuilder.ExcludeFiles() to modify basePath by applying all leading "..\" elements from AddFiles' source string, but that seems like unnecessary complication to me. (normalizedExludeWildcard would become c:\bug*
\exclude.me").

MiroslavBajtos wrote Feb 5, 2013 at 7:16 AM

dotnetjunky wrote Apr 30, 2013 at 11:01 PM

Fixed in changeset c54e5470bf87d003eedc28f3a51546053ed6d91a