@@ -43,9 +43,23 @@ export function resolveFilterSpec(filterSpec: string, basePath?: string, allowEm
4343}
4444
4545export function resolveWildcardPath ( pattern : string , allowEmptyWildcardMatch ?: boolean ) : string [ ] {
46+ let isWindows = os . platform ( ) === 'win32' ;
47+ let toPosixPath = ( path : string ) => path ;
48+ let toNativePath = ( path : string ) => path ;
49+ if ( isWindows ) {
50+ // minimatch assumes paths use /, so on Windows, make paths use /
51+ // This needs to be done both to the pattern and to the filenames.
52+ toPosixPath = ( path : string ) => path . replace ( / \\ / g, "/" ) ;
53+
54+ // tl.find always returns forward slashes. This is problematic with UNC paths because NuGet
55+ // interprets that as a switch argument instead of a path.
56+ toNativePath = ( path : string ) => path . replace ( / \/ / g, "\\" ) ;
57+ }
58+
4659 // Resolve files for the specified value or pattern
4760 var filesList : string [ ] ;
4861 if ( pattern . indexOf ( '*' ) == - 1 && pattern . indexOf ( '?' ) == - 1 ) {
62+
4963 // No pattern found, check literal path to a single file
5064 tl . checkPath ( pattern , 'files' ) ;
5165
@@ -78,14 +92,6 @@ export function resolveWildcardPath(pattern: string, allowEmptyWildcardMatch?: b
7892 // Now we get a list of all files under this root
7993 var allFiles = tl . find ( findPathRoot ) ;
8094
81- let isWindows = os . platform ( ) === 'win32' ;
82- let toPosixPath : ( string ) => string = _ => _ ;
83- if ( isWindows ) {
84- // minimatch assumes paths use /, so on Windows, make paths use /
85- // This needs to be done both to the pattern and to the filenames.
86- toPosixPath = ( path : string ) => path . replace ( "\\" , "/" ) ;
87- }
88-
8995 // Now matching the pattern against all files
9096 // Turn off a bunch of minimatch features to replicate the be
9197 let patternFilter = tl . filter (
@@ -107,5 +113,5 @@ export function resolveWildcardPath(pattern: string, allowEmptyWildcardMatch?: b
107113 }
108114 }
109115
110- return filesList ;
116+ return filesList . map ( toNativePath ) ;
111117}
0 commit comments