File tree Expand file tree Collapse file tree 2 files changed +30
-5
lines changed
src/System.Management.Automation/namespaces
test/powershell/Modules/Microsoft.PowerShell.Management Expand file tree Collapse file tree 2 files changed +30
-5
lines changed Original file line number Diff line number Diff line change @@ -161,14 +161,22 @@ private static string GetCorrectCasedPath(string path)
161
161
else
162
162
{
163
163
// Use GetFileSystemEntries to get the correct casing of this element
164
- var entries = Directory . GetFileSystemEntries ( exactPath , item ) ;
165
- if ( entries . Length > 0 )
164
+ try
166
165
{
167
- exactPath = entries . First ( ) ;
166
+ var entries = Directory . GetFileSystemEntries ( exactPath , item ) ;
167
+ if ( entries . Length > 0 )
168
+ {
169
+ exactPath = entries . First ( ) ;
170
+ }
171
+ else
172
+ {
173
+ // If previous call didn't return anything, something failed so we just return the path we were given
174
+ return path ;
175
+ }
168
176
}
169
- else
177
+ catch
170
178
{
171
- // If previous call didn 't return anything, something failed so we just return the path we were given
179
+ // If we can 't enumerate, we stop and just return the original path
172
180
return path ;
173
181
}
174
182
}
Original file line number Diff line number Diff line change @@ -279,6 +279,23 @@ Describe "Basic FileSystem Provider Tests" -Tags "CI" {
279
279
}
280
280
}
281
281
282
+ Context " Appx path" {
283
+ BeforeAll {
284
+ $skipTest = $true
285
+ if ($IsWindows -and (Get-Command - Name Get-AppxPackage ) -and (Get-AppxPackage Microsoft.WindowsCalculator)) {
286
+ $skipTest = $false
287
+ }
288
+ }
289
+
290
+ It " Can get an appx package item" - Skip:$skipTest {
291
+ $pkgDir = (Get-AppxPackage )[0 ].InstallLocation
292
+
293
+ Get-Item $pkgDir \Calculator.exe - ErrorAction Stop | Should - BeOfType [System.IO.FileInfo ]
294
+ Get-Item - Path $pkgDir - ErrorAction Stop | Should - BeOfType [System.IO.DirectoryInfo ]
295
+ Get-ChildItem - Path $pkgDir - ErrorAction Stop | Should -Not - BeNullOrEmpty
296
+ }
297
+ }
298
+
282
299
Context " Validate basic host navigation functionality" {
283
300
BeforeAll {
284
301
# build semi-complex directory structure to test navigation within
You can’t perform that action at this time.
0 commit comments