Skip to content

Commit fd1fe39

Browse files
authored
Fix Compress-PSResource ignoring .gitkeep and other dotfiles (#1889)
1 parent 5b12325 commit fd1fe39

File tree

2 files changed

+32
-1
lines changed

2 files changed

+32
-1
lines changed

src/code/PublishHelper.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -605,7 +605,8 @@ private bool PackNupkg(string outputDir, string outputNupkgDir, string nuspecFil
605605
Path = nuspecFile,
606606
Exclude = System.Array.Empty<string>(),
607607
Symbols = false,
608-
Logger = NullLogger.Instance
608+
Logger = NullLogger.Instance,
609+
NoDefaultExcludes = true
609610
},
610611
MSBuildProjectFactory.ProjectCreator,
611612
builder);

test/PublishPSResourceTests/CompressPSResource.Tests.ps1

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -396,6 +396,36 @@ Describe "Test Compress-PSResource" -tags 'CI' {
396396
}
397397
}
398398

399+
It "Compress-PSResource includes .gitkeep files (empty and non-empty)" {
400+
$version = "1.0.0"
401+
New-ModuleManifest -Path (Join-Path -Path $script:PublishModuleBase -ChildPath "$script:PublishModuleName.psd1") -ModuleVersion $version -Description "$script:PublishModuleName module"
402+
403+
# Create 'hidden' directory with .gitkeep files
404+
$hiddenDir = Join-Path -Path $script:PublishModuleBase -ChildPath "hidden"
405+
New-Item -Path $hiddenDir -ItemType Directory -Force
406+
407+
# Create empty .gitkeep file in 'hidden' directory
408+
$hiddenGitkeep = Join-Path -Path $hiddenDir -ChildPath ".gitkeep"
409+
New-Item -Path $hiddenGitkeep -ItemType File -Force
410+
411+
Compress-PSResource -Path $script:PublishModuleBase -DestinationPath $script:repositoryPath
412+
413+
# Extract and verify files are included
414+
$nupkgPath = Join-Path -Path $script:repositoryPath -ChildPath "$script:PublishModuleName.$version.nupkg"
415+
$zipPath = Join-Path -Path $script:repositoryPath -ChildPath "$script:PublishModuleName.$version.zip"
416+
Rename-Item -Path $nupkgPath -NewName $zipPath
417+
$unzippedPath = Join-Path -Path $TestDrive -ChildPath "$script:PublishModuleName-gitkeep-test"
418+
New-Item $unzippedPath -ItemType directory -Force
419+
Expand-Archive -Path $zipPath -DestinationPath $unzippedPath
420+
421+
# Verify both .gitkeep files exist
422+
$extractedHiddenkeep = Join-Path -Path $unzippedPath -ChildPath "hidden" | Join-Path -ChildPath ".gitkeep"
423+
424+
Test-Path -Path $extractedHiddenkeep | Should -Be $True
425+
426+
$null = Remove-Item $unzippedPath -Force -Recurse
427+
}
428+
399429
<# Test for Signing the nupkg. Signing doesn't work
400430
It "Compressed Module is able to be signed with a certificate" {
401431
$version = "1.0.0"

0 commit comments

Comments
 (0)