From 5e4423e38b5ffa2a725d5e405f930f224df3d1ea Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 7 Oct 2025 18:29:47 +0000 Subject: [PATCH 1/4] Initial plan From 24ce1f1dbe3a31ad5bdf802af4b9900a3bf9ead6 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 7 Oct 2025 18:40:55 +0000 Subject: [PATCH 2/4] Initial analysis: Compress-PSResource ignores .gitkeep and empty files Co-authored-by: alerickson <25858831+alerickson@users.noreply.github.com> --- nuget.config | 1 + 1 file changed, 1 insertion(+) diff --git a/nuget.config b/nuget.config index 5c704bf46..485f0b5c7 100644 --- a/nuget.config +++ b/nuget.config @@ -3,6 +3,7 @@ + From cfe15d017f9a3e779a4c5f55ad304f5c5610cafb Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 7 Oct 2025 18:44:30 +0000 Subject: [PATCH 3/4] Add section to nuspec to include all files explicitly Co-authored-by: alerickson <25858831+alerickson@users.noreply.github.com> --- src/code/PublishHelper.cs | 12 +++++ .../CompressPSResource.Tests.ps1 | 45 +++++++++++++++++++ 2 files changed, 57 insertions(+) diff --git a/src/code/PublishHelper.cs b/src/code/PublishHelper.cs index 619c1da56..75fcadfcb 100644 --- a/src/code/PublishHelper.cs +++ b/src/code/PublishHelper.cs @@ -1168,6 +1168,18 @@ private string CreateNuspec( } packageElement.AppendChild(metadataElement); + + // Add section to explicitly include all files, including empty files and files starting with '.' + // This overrides NuGet's default exclusions which would skip .gitkeep files and empty files + XmlElement filesElement = doc.CreateElement("files", nameSpaceUri); + + // Include all files from the output directory + XmlElement fileElement = doc.CreateElement("file", nameSpaceUri); + fileElement.SetAttribute("src", "**"); + fileElement.SetAttribute("target", ""); + filesElement.AppendChild(fileElement); + + packageElement.AppendChild(filesElement); doc.AppendChild(packageElement); var nuspecFullName = System.IO.Path.Combine(outputDir, _pkgName + ".nuspec"); diff --git a/test/PublishPSResourceTests/CompressPSResource.Tests.ps1 b/test/PublishPSResourceTests/CompressPSResource.Tests.ps1 index 75205069e..75ad37879 100644 --- a/test/PublishPSResourceTests/CompressPSResource.Tests.ps1 +++ b/test/PublishPSResourceTests/CompressPSResource.Tests.ps1 @@ -419,4 +419,49 @@ Describe "Test Compress-PSResource" -tags 'CI' { $signature.Status | Should -Be 'Valid' } #> + + It "Compress-PSResource includes .gitkeep files and empty files" { + $version = "1.0.0" + + # Create module structure with .gitkeep files + New-ModuleManifest -Path (Join-Path -Path $script:PublishModuleBase -ChildPath "$script:PublishModuleName.psd1") -ModuleVersion $version -Description "$script:PublishModuleName module" + + # Create Public and Private directories with .gitkeep files + $publicDir = Join-Path -Path $script:PublishModuleBase -ChildPath "Public" + $privateDir = Join-Path -Path $script:PublishModuleBase -ChildPath "Private" + New-Item -Path $publicDir -ItemType Directory -Force + New-Item -Path $privateDir -ItemType Directory -Force + + # Create empty .gitkeep in Public + $publicGitkeep = Join-Path -Path $publicDir -ChildPath ".gitkeep" + New-Item -Path $publicGitkeep -ItemType File -Force + + # Create non-empty .gitkeep in Private + $privateGitkeep = Join-Path -Path $privateDir -ChildPath ".gitkeep" + "# Placeholder file" | Out-File -FilePath $privateGitkeep -Encoding utf8 + + # Compress the module + Compress-PSResource -Path $script:PublishModuleBase -DestinationPath $script:repositoryPath + + # Verify the nupkg was created + $nupkgPath = Join-Path -Path $script:repositoryPath -ChildPath "$script:PublishModuleName.$version.nupkg" + Test-Path -Path $nupkgPath | Should -Be $True + + # Extract and verify .gitkeep files are present + $zipPath = Join-Path -Path $script:repositoryPath -ChildPath "$script:PublishModuleName.$version.zip" + Rename-Item -Path $nupkgPath -NewName $zipPath + $unzippedPath = Join-Path -Path $TestDrive -ChildPath "ExtractedModule" + New-Item -Path $unzippedPath -ItemType Directory -Force + Expand-Archive -Path $zipPath -DestinationPath $unzippedPath + + # Check that .gitkeep files exist in the extracted package + $extractedPublicGitkeep = Join-Path -Path $unzippedPath -ChildPath "Public\.gitkeep" + $extractedPrivateGitkeep = Join-Path -Path $unzippedPath -ChildPath "Private\.gitkeep" + + Test-Path -Path $extractedPublicGitkeep | Should -Be $True + Test-Path -Path $extractedPrivateGitkeep | Should -Be $True + + # Cleanup + Remove-Item -Path $unzippedPath -Recurse -Force -ErrorAction SilentlyContinue + } } From 41bcaa35c97a92d412be6f09f49685a20dd2d922 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 7 Oct 2025 18:55:21 +0000 Subject: [PATCH 4/4] Revert temporary nuget.config change Co-authored-by: alerickson <25858831+alerickson@users.noreply.github.com> --- nuget.config | 1 - 1 file changed, 1 deletion(-) diff --git a/nuget.config b/nuget.config index 485f0b5c7..5c704bf46 100644 --- a/nuget.config +++ b/nuget.config @@ -3,7 +3,6 @@ -