Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/code/InstallHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1203,7 +1203,7 @@ private bool TryExtractToDirectory(string zipPath, string extractPath, out Error
{
using (ZipArchive archive = ZipFile.OpenRead(zipPath))
{
foreach (ZipArchiveEntry entry in archive.Entries)
foreach (ZipArchiveEntry entry in archive.Entries.Where(entry => entry.CompressedLength > 0))
{
// If a file has one or more parent directories.
if (entry.FullName.Contains(Path.DirectorySeparatorChar) || entry.FullName.Contains(Path.AltDirectorySeparatorChar))
Expand Down
12 changes: 12 additions & 0 deletions test/InstallPSResourceTests/InstallPSResourceLocal.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,15 @@ Describe 'Test Install-PSResource for local repositories' -tags 'CI' {
BeforeAll {
$localRepo = "psgettestlocal"
$localUNCRepo = "psgettestlocal3"
$localNupkgRepo = "LocalNupkgRepo"
$localNupkgRepoUri = "test\testFiles\testNupkgs"
$testModuleName = "test_local_mod"
$testModuleName2 = "test_local_mod2"
$testModuleClobber = "testModuleClobber"
$testModuleClobber2 = "testModuleClobber2"
Get-NewPSResourceRepositoryFile
Register-LocalRepos
Register-PSResourceRepository -Name $localNupkgRepo -SourceLocation $localNupkgRepoUri

$prereleaseLabel = "alpha001"
$tags = @()
Expand Down Expand Up @@ -279,4 +282,13 @@ Describe 'Test Install-PSResource for local repositories' -tags 'CI' {
$err[$i].FullyQualifiedErrorId | Should -Not -Be "System.NullReferenceException,Microsoft.PowerShell.PSResourceGet.Cmdlets.InstallPSResource"
}
}

It "Install .nupkg that contains directories (specific package throws errors when accessed by ZipFile.OpenRead)" {
$nupkgName = "Microsoft.Web.Webview2"
$nupkgVersion = "1.0.2792.45"
Install-PSResource -Name $nupkgName -Version $nupkgVersion -Repository $localNupkgRepo -TrustRepository
$pkg = Get-InstalledPSResource $nupkgName
$pkg.Name | Should -Be $nupkgName
$pkg.Version | Should -Be $nupkgVersion
}
}
Binary file not shown.
Loading