Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Fix Compress-PSResource ignoring .gitkeep and other dotfiles #1889

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
alerickson merged 7 commits into master from copilot/fix-compress-psresource-issue-2
Oct 15, 2025

Conversation

Copy link
Contributor

Copilot AI commented Oct 7, 2025
edited by alerickson
Loading

Summary

Fixes #1882 and #1819

Compress-PSResource was ignoring certain files and folders due to NuGet's default exclusion patterns, causing signature validation failures when modules included file catalogs.

Problem

When compressing a module for publishing, Compress-PSResource was excluding:

  • Files starting with . (dotfiles like .gitkeep, .gitignore, .editorconfig)
  • Empty files
  • Other patterns in NuGet's default exclude list

This caused issues in the following scenario:

  1. A module contains .gitkeep files (empty or non-empty) in directories like Public/ or Private/
  2. A file catalog is generated that includes these files
  3. Compress-PSResource creates a .nupkg but excludes the .gitkeep files
  4. During installation, signature validation fails due to mismatch between the catalog and package contents

Solution

Added NoDefaultExcludes = true to the PackArgs in PublishHelper.cs. This disables NuGet's default file exclusion behavior, ensuring all files in the module directory are included in the compressed package.

Change in src/code/PublishHelper.cs:

var runner = new PackCommandRunner(
 new PackArgs
 {
 CurrentDirectory = outputDir,
 OutputDirectory = outputNupkgDir,
 Path = nuspecFile,
 Exclude = System.Array.Empty<string>(),
 Symbols = false,
 Logger = NullLogger.Instance,
 NoDefaultExcludes = true // ← Added this line
 },
 MSBuildProjectFactory.ProjectCreator,
 builder);

Verification

Manually tested to confirm:

  • ✅ Empty .gitkeep files are now included
  • ✅ Non-empty .gitkeep files are now included with correct content
  • ✅ Other dotfiles (.gitignore, .editorconfig) are now included
  • ✅ Hidden directories (.vscode) are now included
  • ✅ Basic module compression functionality remains unchanged
  • ✅ Directory structure is preserved correctly

Also added a test case in CompressPSResource.Tests.ps1 to verify .gitkeep files (both empty and non-empty) are included in compressed packages.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • 1k9vsblobprodcus379.vsblob.vsassets.io
    • Triggering command: /usr/bin/dotnet publish --configuration Debug --framework net472 --output bin/Debug/net472/publish (dns block)
  • 37cvsblobprodcus359.vsblob.vsassets.io
    • Triggering command: /usr/bin/dotnet publish --configuration Debug --framework net472 --output bin/Debug/net472/publish (dns block)
  • 4myvsblobprodcus32.vsblob.vsassets.io
    • Triggering command: /usr/bin/dotnet publish --configuration Debug --framework net472 --output bin/Debug/net472/publish (dns block)
  • 51yvsblobprodcus36.vsblob.vsassets.io
    • Triggering command: /usr/bin/dotnet publish --configuration Debug --framework net472 --output bin/Debug/net472/publish (dns block)
  • 5dkvsblobprodcus355.vsblob.vsassets.io
    • Triggering command: /usr/bin/dotnet publish --configuration Debug --framework net472 --output bin/Debug/net472/publish (dns block)
  • 7devsblobprodcus323.vsblob.vsassets.io
    • Triggering command: /usr/bin/dotnet publish --configuration Debug --framework net472 --output bin/Debug/net472/publish (dns block)
  • 7k6vsblobprodcus337.vsblob.vsassets.io
    • Triggering command: /usr/bin/dotnet publish --configuration Debug --framework net472 --output bin/Debug/net472/publish (dns block)
  • 7tjvsblobprodcus341.vsblob.vsassets.io
    • Triggering command: /usr/bin/dotnet publish --configuration Debug --framework net472 --output bin/Debug/net472/publish (dns block)
  • bcnvsblobprodcus378.vsblob.vsassets.io
    • Triggering command: /usr/bin/dotnet publish --configuration Debug --framework net472 --output bin/Debug/net472/publish (dns block)
  • c50vsblobprodcus330.vsblob.vsassets.io
    • Triggering command: /usr/bin/dotnet publish --configuration Debug --framework net472 --output bin/Debug/net472/publish (dns block)
  • c78vsblobprodcus322.vsblob.vsassets.io
    • Triggering command: /usr/bin/dotnet publish --configuration Debug --framework net472 --output bin/Debug/net472/publish (dns block)
  • dlbvsblobprodcus316.vsblob.vsassets.io
    • Triggering command: /usr/bin/dotnet publish --configuration Debug --framework net472 --output bin/Debug/net472/publish (dns block)
  • fdpvsblobprodcus345.vsblob.vsassets.io
    • Triggering command: /usr/bin/dotnet publish --configuration Debug --framework net472 --output bin/Debug/net472/publish (dns block)
  • gbsvsblobprodcus365.vsblob.vsassets.io
    • Triggering command: /usr/bin/dotnet publish --configuration Debug --framework net472 --output bin/Debug/net472/publish (dns block)
  • jd4vsblobprodcus366.vsblob.vsassets.io
    • Triggering command: /usr/bin/dotnet publish --configuration Debug --framework net472 --output bin/Debug/net472/publish (dns block)
  • kh4vsblobprodcus325.vsblob.vsassets.io
    • Triggering command: /usr/bin/dotnet publish --configuration Debug --framework net472 --output bin/Debug/net472/publish (dns block)
  • kmuvsblobprodcus389.vsblob.vsassets.io
    • Triggering command: /usr/bin/dotnet publish --configuration Debug --framework net472 --output bin/Debug/net472/publish (dns block)
  • l49vsblobprodcus358.vsblob.vsassets.io
    • Triggering command: /usr/bin/dotnet publish --configuration Debug --framework net472 --output bin/Debug/net472/publish (dns block)
  • m6xvsblobprodcus342.vsblob.vsassets.io
    • Triggering command: /usr/bin/dotnet publish --configuration Debug --framework net472 --output bin/Debug/net472/publish (dns block)
  • pkvvsblobprodcus321.vsblob.vsassets.io
    • Triggering command: /usr/bin/dotnet publish --configuration Debug --framework net472 --output bin/Debug/net472/publish (dns block)
  • s4uvsblobprodcus326.vsblob.vsassets.io
    • Triggering command: /usr/bin/dotnet publish --configuration Debug --framework net472 --output bin/Debug/net472/publish (dns block)
  • tphvsblobprodcus375.vsblob.vsassets.io
    • Triggering command: /usr/bin/dotnet publish --configuration Debug --framework net472 --output bin/Debug/net472/publish (dns block)
  • uy6vsblobprodcus34.vsblob.vsassets.io
    • Triggering command: /usr/bin/dotnet publish --configuration Debug --framework net472 --output bin/Debug/net472/publish (dns block)
  • yttvsblobprodcus357.vsblob.vsassets.io
    • Triggering command: /usr/bin/dotnet publish --configuration Debug --framework net472 --output bin/Debug/net472/publish (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

This section details on the original issue you should resolve

<issue_title>Compress-PSResource ignores files and folders</issue_title>
<issue_description>### Prerequisites

  • Write a descriptive title.
  • Make sure you are able to repro it on the latest released version
  • Search the existing issues.

Steps to reproduce

Compress-PSResource completely ignored and didn't compress following paths while preparing a module for publishing:

  • Public\.gitkeep # the folder contiain only this file, and the file IS empty
  • Private\.gitkeep # the folder contiain only this file, and the file IS NOT empty

Previous pipeline step generated file catalog for the module, with the two pats included, and published module failed installing as there was signature mismatch.

The issue is probably related to #1819

Expected behavior

All files and folders are compressed and part of the nupkg file

Actual behavior

Certain paths get ignored

Error details

Environment data

-

Visuals

No response</issue_description>

<agent_instructions>The issue seem to be here in PSResourceGet/src/code/PublishHelper.cs on Line 601

new PackArgs should have NoDefaultExcludes set to true
</agent_instructions>

Comments on the Issue (you are @copilot in this section)

Fixes #1882

✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 4 commits October 7, 2025 19:50
Co-authored-by: alerickson <25858831+alerickson@users.noreply.github.com>
...d files
Co-authored-by: alerickson <25858831+alerickson@users.noreply.github.com>
Co-authored-by: alerickson <25858831+alerickson@users.noreply.github.com>
Co-authored-by: alerickson <25858831+alerickson@users.noreply.github.com>
Copilot AI changed the title (削除) [WIP] Fix Compress-PSResource to include .gitkeep files (削除ここまで) (追記) Fix Compress-PSResource ignoring .gitkeep and other dotfiles (追記ここまで) Oct 7, 2025
Copilot AI requested a review from alerickson October 7, 2025 20:04
Copilot finished work on behalf of alerickson October 7, 2025 20:04
Copy link
Member

/azp run PowerShell.PSResourceGet

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

Copy link
Member

/azp run PowerShell.PSResourceGet

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

Copy link
Member

/azp run PowerShell.PSResourceGet

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

Copy link
Member

for issue #1819 can we add a test, by publishing the created module to the gallery and saving/installing it from there

Copy link
Member

alerickson commented Oct 14, 2025
edited
Loading

I don't really think it's necessary to publish to the Gallery because the issue isn't with publishing it's with the act of packing/compressing. The method PackNupkg() gets called for both Compress-PSResource and Publish-PSResource, so to reduce test redundancy and time it takes to run tests (particularly since the Windows test suite occasionally times out) I think it makes sense to just have 1 test here

anamnavi reacted with thumbs up emoji

@anamnavi anamnavi marked this pull request as ready for review October 14, 2025 21:29
@alerickson alerickson merged commit fd1fe39 into master Oct 15, 2025
10 of 12 checks passed
@alerickson alerickson deleted the copilot/fix-compress-psresource-issue-2 branch October 15, 2025 21:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@anamnavi anamnavi anamnavi approved these changes

@adityapatwardhan adityapatwardhan Awaiting requested review from adityapatwardhan adityapatwardhan is a code owner

@SydneyhSmith SydneyhSmith Awaiting requested review from SydneyhSmith SydneyhSmith is a code owner

+1 more reviewer

@alerickson alerickson alerickson approved these changes

Reviewers whose approvals may not affect merge requirements

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Compress-PSResource ignores files and folders

AltStyle によって変換されたページ (->オリジナル) /