8
8
using System . Threading ;
9
9
using System . Threading . Tasks ;
10
10
using AzureSign . Core ;
11
+ using Microsoft . Extensions . FileSystemGlobbing ;
12
+ using Microsoft . Extensions . FileSystemGlobbing . Abstractions ;
11
13
using Microsoft . Extensions . Logging ;
12
14
using Microsoft . Extensions . Logging . Console ;
13
15
using RSAKeyVaultProvider ;
@@ -89,7 +91,14 @@ internal HashSet<string> AllFiles
89
91
{
90
92
if ( _allFiles is null )
91
93
{
92
- _allFiles = new HashSet < string > ( Files ) ;
94
+ _allFiles = [ ] ;
95
+ Matcher matcher = new ( ) ;
96
+
97
+ foreach ( string file in Files )
98
+ {
99
+ Add ( _allFiles , matcher , file ) ;
100
+ }
101
+
93
102
if ( ! string . IsNullOrWhiteSpace ( InputFileList ) )
94
103
{
95
104
foreach ( string line in File . ReadLines ( InputFileList ) )
@@ -99,11 +108,36 @@ internal HashSet<string> AllFiles
99
108
continue ;
100
109
}
101
110
102
- _allFiles . Add ( line ) ;
111
+ Add ( _allFiles , matcher , line ) ;
112
+ }
113
+ }
114
+
115
+ PatternMatchingResult results = matcher . Execute ( new DirectoryInfoWrapper ( new DirectoryInfo ( "." ) ) ) ;
116
+
117
+ if ( results . HasMatches )
118
+ {
119
+ foreach ( var result in results . Files )
120
+ {
121
+ _allFiles . Add ( result . Path ) ;
103
122
}
104
123
}
105
124
}
125
+
106
126
return _allFiles ;
127
+
128
+ static void Add ( HashSet < string > collection , Matcher matcher , string item )
129
+ {
130
+ // We require explicit glob pattern wildcards in order to treat it as a glob. e.g.
131
+ // dir/ will not be treated as a directory. It must be explicitly dir/*.exe or dir/**/*.exe, for example.
132
+ if ( item . Contains ( '*' ) )
133
+ {
134
+ matcher . AddInclude ( item ) ;
135
+ }
136
+ else
137
+ {
138
+ collection . Add ( item ) ;
139
+ }
140
+ }
107
141
}
108
142
}
109
143
0 commit comments