PowerShell / PowerShell/PSResourceGet

Update-ModuleManifest corrupts PrivateData in module manifest

Open
#307 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Area-InfoFile Issue-Bug
Dominant language
C#
Stars
576
Forks
114
Avg merge
1d 2h
Merged PRs (30d)
7

Description

This bug by @jformacek is copied from https://github.com/MicrosoftDocs/PowerShell-Docs/issues/6767

Usage of this command on existing module manifest breaks it's content. I wanted to use this command inside build pipeline to update ModuleVersion attribute, but found at least 2 things that got broken on my manifest module:

  • RequiredAssembles attribute: I have something like below in my manifest file, and Update-ModuleManifest removes this attribute completely
RequiredAssemblies = if($PSEdition -eq 'Desktop') {@('lib\net45\someAssembly.dll')} else {$null}
  • PrivateData attribute: I have added additional content as hashtable Messages to module's PrivateData as addtional hashtable aside from PSData as shown below, however, Update-ModuleManifest changes the Messages hashtable to Messages = 'System.Collections.Hashtable', which breaks the logic of module
PrivateData = @{
    Messages = @{
        NotInitialized = 'Call Initialize-Module before running other cmdlets.'
    }
    PSData = @{
    # ... standard content
    }

Would be great to update the command so as it does not change the attributes that are not passed from command line, or at least document here what gets changed/reset when command is run, so as users are not surprised after running it.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the Update-ModuleManifest command and reproduce the report with a manifest containing RequiredAssemblies and nested PrivateData.Messages. Compare the manifest before and after updating only ModuleVersion. Done means unpassed attributes remain intact, including the nested Messages hashtable, with regression coverage for both reported cases.

Written by the indexing model from the issue text.

Assessment

Tech stack
powershell
Domain
tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.