Skip to content

Publish-Module Violates Single Responsibility Principle #1393

Open

Description

Summary of the new feature / enhancement

As a user, I expect Publish-Module to publish a module, not package AND publish a module. As a user, I also expect that I can issue Package-Module to create a new module package that can then be published to one or more places, such as the PowerShellGallery and/or private package feeds.

Proposed technical implementation details (optional)

For example, the following workflows are what I desire:

PS C:\MyProject> Package-Module -Path ./out/MyModule

 ModuleName      Version    Path
 ----------      -------    -------------------------
 MyModule        1.0.0      C:\MyProject\artifacts\MyModule-1.0.0.nupkg

and then, combined with Publish-Module, perhaps something like:

PS C:\MyProject> Package-Module -Path ./out/MyModule -PassThru | Publish-Module ...

Activity

  1. ThomasNieto commented on Sep 6, 2023

    @ThomasNieto
    Contributor

    I also have had the same concern for a while. I would have wanted a New-PSResource or Build-PSResource and publish only pushes the resource to the repository.

  2. ThomasNieto commented on Sep 6, 2023

    @ThomasNieto
    Contributor

    Sydney Smith (@SydneyhSmith) I know this is close to release but the existing functionality is already there just splitting it into two cmdlets.

  3. SydneyhSmith commented on Sep 6, 2023

    @SydneyhSmith
    Collaborator

    We have been wanting to support publishing already built packages (nupkgs), and may need to in order to support certain repositories in the future...this won't block RC but I agree that it would be nice to have a Build-PSResource type command and support either unpacked modules or nupkgs as input for Publish-PSResource, probably as different parameter sets

  4. SydneyhSmith commented on Sep 6, 2023

    @SydneyhSmith
    Collaborator

    Today you can sort of accomplish this by using the -DestinationPath parameter on Publish

  5. leoniDEV commented on Oct 25, 2023

    @leoniDEV

    The problem with the -DestinationPath is that the command still try to upload the package to remote repository and if you don't provide an API key the command fail (after blocking the command line for a while) with a 401 error

  6. added 2 commits that reference this issue on Nov 22, 2023
  7. JustinGrote commented on May 14, 2025

    @JustinGrote
    Contributor

    I don't think it should be a separate cmdlet but -DestinationPath should be part of a separate parameterset. Unfortunately that would be abreaking change now for anyone already expecting it to do both.

    As a workaround, you can Register-PSResourceRepository -Name 'Local' -Uri /path/you/want/to/save/the/nupkg and then publish to that and get the desired effect (make a nupkg without publishing to gallery/otherwise)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions