MicrosoftDocs / PowerShell-Docs-PSGet

The official documentation for PowerShellGet and PowerShell Gallery
https://docs.microsoft.com/powershell/gallery/overview
Creative Commons Attribution 4.0 International
23 stars 24 forks source link

Publish-Module -Name is incorrect. Publish-Module -Path is correct #125

Closed tonymet closed 5 months ago

tonymet commented 5 months ago

Type of issue

Code doesn't work

Feedback

Publish-Module -Namefails with the error "the module with name XYZ does not exist". The correct command is PublishModule -Path

Complete Working Example

$parameters = @{
    Path        = Get-Item "win-fonts"
    NuGetApiKey = $secrets.NuGetApiKey
    LicenseUri  = "https://github.com/tonymet/powershell-scripts/blob/master/LICENSE"
    Tag         = "fonts","powershell","powershell-module","PSEdition_Core","Windows"
    ReleaseNote = "Updated the ActiveDirectory DSC Resources to support adding users."
    Repository  = "PSGallery"
}

Publish-Module @parameters  

Page URL

https://learn.microsoft.com/en-us/powershell/module/powershellget/publish-module?view=powershellget-3.x

Content source URL

https://github.com/MicrosoftDocs/PowerShell-Docs-PSGet/blob/main/powershell-gallery/powershellget-3.x/PowerShellGet/Publish-Module.md

Author

@sdwheeler

Document Id

6b49c538-9eea-8c90-18fa-c602979056e6

sdwheeler commented 5 months ago

The docs for v3 of PowerShellGet is for the proxy module. Publish-Module is a proxy for Publish-PSResource in the new Microsoft.PowerShell.PSResource module, which doesn't support the -Name parameter.

The example works for PowerShellGet v2, but needs to updated for the v3 docs.

tonymet commented 5 months ago

The docs for v3 of PowerShellGet is for the proxy module. Publish-Module is a proxy for Publish-PSResource

What tools can I use to see which one I have installed? Here are the local docs

❯ help Publish-PSResource

NAME
    Publish-PSResource

SYNTAX
    Publish-PSResource [-Path] <string> [-ApiKey <string>] [-Repository <string>] [-DestinationPath       
    <string>] [-Credential <pscredential>] [-SkipDependenciesCheck] [-SkipModuleManifestValidate]
    [-Proxy <uri>] [-ProxyCredential <pscredential>] [-WhatIf] [-Confirm] [<CommonParameters>]

NAME
    Publish-Module

SYNTAX
    Publish-Module -Name <string> [-RequiredVersion <string>] [-NuGetApiKey <string>] [-Repository        
    <string>] [-Credential <pscredential>] [-FormatVersion {2.0}] [-ReleaseNotes <string[]>] [-Tags       
    <string[]>] [-LicenseUri <uri>] [-IconUri <uri>] [-ProjectUri <uri>] [-Exclude <string[]>] [-Force]   
    [-AllowPrerelease] [-SkipAutomaticTags] [-WhatIf] [-Confirm] [<CommonParameters>]

    Publish-Module -Path <string> [-NuGetApiKey <string>] [-Repository <string>] [-Credential
    <pscredential>] [-FormatVersion {2.0}] [-ReleaseNotes <string[]>] [-Tags <string[]>] [-LicenseUri     
    <uri>] [-IconUri <uri>] [-ProjectUri <uri>] [-Force] [-SkipAutomaticTags] [-WhatIf] [-Confirm]        
    [<CommonParameters>]
sdwheeler commented 5 months ago
PS> Get-Module -ListAvailable PowerShellGet

    Directory: C:\Users\useranem\Documents\PowerShell\Modules

ModuleType Version    PreRelease Name                                PSEdition ExportedCommands
---------- -------    ---------- ----                                --------- ----------------
Script     2.9.0      preview    PowerShellGet                       Desk      {Find-Command, Find-DscResource, Find-M…

    Directory: C:\Program Files\PowerShell\Modules

ModuleType Version    PreRelease Name                                PSEdition ExportedCommands
---------- -------    ---------- ----                                --------- ----------------
Script     2.2.5                 PowerShellGet                       Desk      {Find-Command, Find-DSCResource, Find-M…

    Directory: C:\program files\powershell\7.2\Modules

ModuleType Version    PreRelease Name                                PSEdition ExportedCommands
---------- -------    ---------- ----                                --------- ----------------
Script     2.2.5                 PowerShellGet                       Desk      {Find-Command, Find-DSCResource, Find-M…

    Directory: C:\Program Files\WindowsPowerShell\Modules

ModuleType Version    PreRelease Name                                PSEdition ExportedCommands
---------- -------    ---------- ----                                --------- ----------------
Script     1.0.0.1               PowerShellGet                       Desk      {Install-Module, Find-Module, Save-Modu…