Skip to content

Conversation

Copilot
Copy link

@Copilot Copilot AI commented Oct 7, 2025

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 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 Copilot AI requested a review from alerickson October 7, 2025 20:04
Copilot finished work on behalf of alerickson October 7, 2025 20:04
@alerickson
Copy link
Member

/azp run PowerShell.PSResourceGet

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@alerickson
Copy link
Member

/azp run PowerShell.PSResourceGet

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@alerickson
Copy link
Member

/azp run PowerShell.PSResourceGet

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Compress-PSResource ignores files and folders
2 participants