Home: Cross-platform glob pattern and path issues

Created on 4 Oct 2016  路  4Comments  路  Source: NuGet/Home

NuGet/NuGet.Client#909 fixes a few issues, but there are more.

  1. PathResolver.IsWildcardSearch(...) only checks for presence of a star character (*), but PathResolver.WildcardToRegex(...) supports question mark character (?).
  2. NuSpec examples show glob patterns with both forward slash (/) and backslash (\), but it is not clear if NuGet intends to support both interchangeably on both Windows and Unix-flavored operating systems.
  3. Code to handle glob patterns/paths with forward- or backslashes is scattered around the code base (example), which makes bug fixing and testing more difficult.
Pack Push Backlog Xplat 2 NuGet.exe Bug

Most helpful comment

Added all related issues I could find that deal with paths cross-plat both pack and push related ones.
Assigning @rohit21agrawal and @zhili1208 to this mega-issue as they are the ones that had multiple of these assigned to them.

All 4 comments

Adding another issue to the list:

3959

Here's the description from there:

Globbing patterns in nuspec using forward slashes do not match files. The same pattern with backslashes works.

Details

Using NuGet.exe 3.5.0.1938 on Windows 10

Repro

  1. Create folder layout
TestPackage.nuspec
folder/
     test.txt
  1. Use this nuspec
<?xml version="1.0" encoding="utf-8"?>
<package xmlns="http://schemas.microsoft.com/packaging/2012/06/nuspec.xsd">
  <metadata>
    <id>TestPackage</id>
    <version>1.0.0</version>
    <authors>name</authors>
    <description>description</description>
  </metadata>
  <files>
    <file src="folder/*.txt" target="dir1/" />
    <file src="folder\*.txt" target="dir2/" />
  </files>
</package>
  1. nuget.exe pack TestPackage.nuspec

Expected result

NuGet package contains:

<nupkg>/
   TestPackage.nuspec
   dir1/
       test.txt
   dir2/
        test.txt

Actual result

The globbing pattern for folder/*.txt does not match files, but folder\*.txt does.

<nupkg>/
   TestPackage.nuspec
   dir2/
       test.txt

Threw in a couple of pack issues with forward/backward slashes.

Added all related issues I could find that deal with paths cross-plat both pack and push related ones.
Assigning @rohit21agrawal and @zhili1208 to this mega-issue as they are the ones that had multiple of these assigned to them.

The glob syntax doesn't seem to be documented anywhere. Would be nice to add this to the TODO list. In particular I'd love to know how to negate a match e.g. *!(preview)*.nupkg (find all .nupkg files without preview in the file name).

Was this page helpful?
0 / 5 - 0 ratings