PSResourceGet icon indicating copy to clipboard operation
PSResourceGet copied to clipboard

Publish-Module Violates Single Responsibility Principle

Open fourpastmidnight opened this issue 2 years ago • 5 comments

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 ...

fourpastmidnight avatar Sep 06 '23 20:09 fourpastmidnight

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.

ThomasNieto avatar Sep 06 '23 21:09 ThomasNieto

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

ThomasNieto avatar Sep 06 '23 21:09 ThomasNieto

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

SydneyhSmith avatar Sep 06 '23 22:09 SydneyhSmith

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

SydneyhSmith avatar Sep 06 '23 22:09 SydneyhSmith

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

leoniDEV avatar Oct 25 '23 16:10 leoniDEV

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)

JustinGrote avatar May 14 '25 15:05 JustinGrote