-
Notifications
You must be signed in to change notification settings - Fork 129
PowerShellGet 3.0 #185
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
PowerShellGet 3.0 #185
Changes from 1 commit
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
237f4c4
draft of PSGet3.0 proposal (#4)
SteveL-MSFT fe95b3f
address feedback
SteveL-MSFT fe59946
a few additiona clarifications
SteveL-MSFT c714547
update feedback time
SteveL-MSFT 3e904e5
add note to return better error message if there is PSGallery outage
SteveL-MSFT a4a986a
Update 2-Draft-Accepted/RFCxxxx-PowerShellGet-3.0.md
SteveL-MSFT cc293e7
address Mark and Dongbo's feedback
SteveL-MSFT bd58ae8
address feedback
SteveL-MSFT f271cef
add note to notify users of new versions of modules in future
SteveL-MSFT 6be130f
address latest feedback
SteveL-MSFT 08bc329
address feedback
SteveL-MSFT File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,242 @@ | ||
--- | ||
RFC: RFCxxxx | ||
Author: Steve Lee | ||
Status: Draft | ||
SupercededBy: N/A | ||
Version: 0.1 | ||
Area: PowerShellGet | ||
Comments Due: 7/30 | ||
Plan to implement: Yes | ||
--- | ||
|
||
# PowerShellGet 3.0 Module | ||
|
||
PowerShellGet has enabled an active community to publish and install PowerShell | ||
Modules. | ||
However, it has some architectural and design limitations that prevent it from | ||
moving forward more quickly. | ||
This RFC proposes some significant changes to address this. | ||
|
||
> [!NOTE] | ||
> There are no intentions to break existing PSGet v2 users so existing | ||
> users can stay on PSGet v2 and that will continue to work. | ||
|
||
## Motivation | ||
|
||
As a PowerShell user, | ||
I can discover how to install missing cmdlets, | ||
so that I can be more productive. | ||
|
||
As a PowerShellGet contributor, | ||
I can more easily contribute code, | ||
so that PowerShellGet evolves more quickly. | ||
|
||
## User Experience | ||
|
||
```powershell | ||
PS> Get-Satisfaction | ||
Get-Satisfaction : The term 'Get-Satisfaction' is not recognized as the name of a cmdlet, function, script file, or operable program. | ||
Check the spelling of the name, or if a path was included, verify that the path is correct and try again. | ||
At line:1 char:1 | ||
+ Get-Satisfaction | ||
+ ~~~ | ||
+ CategoryInfo : ObjectNotFound: (Get-Satisfaction:String) [], CommandNotFoundException | ||
+ FullyQualifiedErrorId : CommandNotFoundException | ||
|
||
Suggestion: You can obtain `Get-Satisfaction` by running `Install-PSResource HappyDays`. | ||
SteveL-MSFT marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
PS> Install-PSResource HappyDays | ||
``` | ||
|
||
## Specification | ||
|
||
### Rewrite of PowerShellGet | ||
SteveL-MSFT marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
PowerShellGet is currently written as PowerShell script with a dependency on PackageManagement. | ||
Proposal is to write PSResource in C# to reduce complexity and make easier to maintain. | ||
SteveL-MSFT marked this conversation as resolved.
Show resolved
Hide resolved
|
||
In addition, remove dependency on PackageManagement completely as well as dependency on | ||
SteveL-MSFT marked this conversation as resolved.
Show resolved
Hide resolved
|
||
nuget.exe. | ||
This module will only use REST APIs to get and publish nupkgs. | ||
SteveL-MSFT marked this conversation as resolved.
Show resolved
Hide resolved
|
||
This module would be shipped in PowerShell 7. | ||
|
||
### Side-by-side with PowerShellGet | ||
|
||
To ease transition due to the enormity of the breaking change, this module will | ||
SteveL-MSFT marked this conversation as resolved.
Show resolved
Hide resolved
|
||
have a different names for the cmdlets to allow for side by side use | ||
with the existing PowerShellGet module. | ||
SteveL-MSFT marked this conversation as resolved.
Show resolved
Hide resolved
|
||
Since the current PowerShellGet 2.x version is a script module and this new one | ||
is a C# based module, they can coexist side-by-side. | ||
SteveL-MSFT marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
### Cmdlet compatibility | ||
|
||
Function wrappers will be provided to provide compatibility with the two most often | ||
used cmdlets: `Install-Module` and `Find-Module`. | ||
These cmdlets will output a warning to use the new cmdlets. | ||
SteveL-MSFT marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
### Local cache | ||
|
||
Rather than connecting to PSGallery and other repositories for finding modules, | ||
the user must explicitly request the current metadata of | ||
modules from the repositories and that is cached locally. | ||
`Find-PSResource` (see below) works against this local cache. | ||
This will also enable changes in PowerShell to use `Find-PSResource -Type Command` to look | ||
SteveL-MSFT marked this conversation as resolved.
Show resolved
Hide resolved
|
||
in this cache when it can't find a command and suggest to the user the module to install to | ||
get that command. | ||
This will be a local json file containing only the latest version of each module. | ||
The cache will be stored in the user path. | ||
There is no system cache that is shared. | ||
SteveL-MSFT marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
Example cache entry: | ||
|
||
```json | ||
{ | ||
"name": "This is my module", | ||
"version": "1.0.0.0", | ||
"type": "module", | ||
"tags": [ | ||
"Linux", | ||
"PSEdition_Core", | ||
"PSEdition_Desktop", | ||
"AzureAutomation" | ||
] | ||
} | ||
``` | ||
|
||
An example cache with 5000 resources is ~700KB in compressed json form. | ||
SteveL-MSFT marked this conversation as resolved.
Show resolved
Hide resolved
SteveL-MSFT marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
### Automatic updating of the cache | ||
SteveL-MSFT marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
On any operation that reaches out to a repository, a REST API will be called to | ||
see if the hash of the cache matches the current cache and if not, a new one | ||
is downloaded. | ||
SteveL-MSFT marked this conversation as resolved.
Show resolved
Hide resolved
|
||
If the repository doesn't support this new API, it falls back to current behavior | ||
in PSGet v2. | ||
SteveL-MSFT marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
### Repository management | ||
|
||
`Register-PSResourceRepository` will allow for registering additional repositories. | ||
A `-Default` switch enables registering PSGallery should it be accidentally removed. | ||
The `-URL` will accept the HTTP address without the need to specify `/api/v2` as | ||
that will be assumed and discovered at runtime. | ||
SteveL-MSFT marked this conversation as resolved.
Show resolved
Hide resolved
|
||
Support for local filesystem repositories must be maintained. | ||
A `-InstallationPolicy` switch accepts `Trusted` or `Untrusted` (default) indicating | ||
SteveL-MSFT marked this conversation as resolved.
Show resolved
Hide resolved
|
||
whether to prompt the user when installing resources from that repository. | ||
SteveL-MSFT marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
`Get-PSResourceRepository` will list out the registered repositories. | ||
|
||
`Set-PSResourceRepository` can be used to update a repository URL or installation policy. | ||
|
||
`Unregister-PSResourceRepository` can be used to un-register a repository. | ||
|
||
SteveL-MSFT marked this conversation as resolved.
Show resolved
Hide resolved
|
||
### Finding resources | ||
|
||
Current design of PowerShellGet is to have different cmdlets for each of the | ||
different resources types that it supports: | ||
|
||
`Find-Command` | ||
SteveL-MSFT marked this conversation as resolved.
Show resolved
Hide resolved
|
||
`Find-DscResource` | ||
`Find-Module` | ||
`Find-RoleCapability` | ||
`Find-Script` | ||
|
||
Instead, these will be abstracted by a `Find-PSResource` cmdlet. | ||
A `-Type` parameter will accept an array of types to allow filtering. | ||
SteveL-MSFT marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
With support of the generic `PSResource`, this means we can also find and | ||
install arbitrary nupkgs that may only contain an assembly the user wants to | ||
use in their script. | ||
SteveL-MSFT marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
If the local cache does not exist, the cmdlet will call `Update-PSResourceCache` | ||
SteveL-MSFT marked this conversation as resolved.
Show resolved
Hide resolved
|
||
first and then attempt a search. | ||
However, this cmdlet does not update the cache if one exists. | ||
SteveL-MSFT marked this conversation as resolved.
Show resolved
Hide resolved
SteveL-MSFT marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
### Installing resources | ||
|
||
`Install-PSResource` will only work for modules. | ||
SteveL-MSFT marked this conversation as resolved.
Show resolved
Hide resolved
SteveL-MSFT marked this conversation as resolved.
Show resolved
Hide resolved
SteveL-MSFT marked this conversation as resolved.
Show resolved
Hide resolved
|
||
A `-AllowPrerelease` switch allows installing prerelease versions. | ||
SteveL-MSFT marked this conversation as resolved.
Show resolved
Hide resolved
|
||
Other types will use `Save-PSResource` (see below). | ||
A `-Repository` parameter accepts a specific repository name. | ||
If `-Repository` is not specified and the same resource is found in multiple | ||
repositories, then the resource is automatically installed quietly from the | ||
SteveL-MSFT marked this conversation as resolved.
Show resolved
Hide resolved
|
||
trusted repository with the highest version matching the `-Version` parameter | ||
(if specified, otherwise newest non-prerelease version unless `-AllowPrerelease` | ||
is used). | ||
If there are no trusted repositories matching the query, then the newest version | ||
SteveL-MSFT marked this conversation as resolved.
Show resolved
Hide resolved
|
||
fulfilling the query will be prompted to be installed. | ||
If there are multiple repositories with the same trust level containing the same | ||
version, the first one is used. | ||
SteveL-MSFT marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
`-AllowUntrusted` can be used to suppress being prompted for untrusted sources. | ||
`-AllowDifferentPublisher` can be used to suppress being prompted if the publisher | ||
of the module is different from the currently installed version. | ||
`-AllowReinstall` can be used to re-install a module. | ||
SteveL-MSFT marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
A `-Quiet` switch will suppress progress information. | ||
SteveL-MSFT marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
SteveL-MSFT marked this conversation as resolved.
Show resolved
Hide resolved
|
||
### Dependencies and version management | ||
|
||
`Install-PSResource` can accept a path to a psd1 file (using `-RequiredModulesFile`) | ||
or a hashtable (using `-RequiredModules`) where the key is the module name and the | ||
SteveL-MSFT marked this conversation as resolved.
Show resolved
Hide resolved
|
||
value is either the required version specified using Nuget version range syntax or | ||
SteveL-MSFT marked this conversation as resolved.
Show resolved
Hide resolved
|
||
a hash table where `repository` is set to the URL of the repository and | ||
`version` contains the [Nuget version range syntax](https://docs.microsoft.com/en-us/nuget/reference/package-versioning#version-ranges-and-wildcards). | ||
SteveL-MSFT marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
```powershell | ||
SteveL-MSFT marked this conversation as resolved.
Show resolved
Hide resolved
|
||
Install-PSResource -RequiredModules @{ | ||
"Configuration" = "[1.3.1,2.0)" | ||
SteveL-MSFT marked this conversation as resolved.
Show resolved
Hide resolved
|
||
"Pester" = @{ | ||
version = "[4.4.2,4.7.0]" | ||
repository = "https://www.powershellgallery.com" | ||
SteveL-MSFT marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
} | ||
``` | ||
|
||
### Saving resources | ||
SteveL-MSFT marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
With the removal of PackageManagement, there is still a need to support saving | ||
arbitrary nupkgs (assemblies) used for scripts. | ||
|
||
`Save-PSResource -Type Library` will download nupkgs that have a `lib` folder. | ||
A `-AllowPrerelease` switch allows saving prerelease versions. | ||
SteveL-MSFT marked this conversation as resolved.
Show resolved
Hide resolved
|
||
The dependent native library in `runtimes` matching the current system runtime | ||
SteveL-MSFT marked this conversation as resolved.
Show resolved
Hide resolved
|
||
will be copied to the same destination. | ||
|
||
SteveL-MSFT marked this conversation as resolved.
Show resolved
Hide resolved
|
||
This cmdlet has the same parameters as `Install-PSResource` with the addition | ||
of mandatory `-Path` or `-LiteralPath` parameters. | ||
SteveL-MSFT marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
### Updating resources | ||
|
||
`Update-PSResource` will update all resources to most recent minor version by | ||
SteveL-MSFT marked this conversation as resolved.
Show resolved
Hide resolved
|
||
default. | ||
A `-OnlyMinorUpdates` switch will allow only updating to newer minor version. | ||
SteveL-MSFT marked this conversation as resolved.
Show resolved
Hide resolved
|
||
If the installed resource is a pre-release, it will automatically update to | ||
latest prerelease or stable version (if available). | ||
SteveL-MSFT marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
### Publishing resources | ||
SteveL-MSFT marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
`Publish-PSResource` will supporting publishing modules and scripts. | ||
Modules will be given as a path to the module folder. | ||
SteveL-MSFT marked this conversation as resolved.
Show resolved
Hide resolved
|
||
Publishing by name and version is no longer supported. | ||
SteveL-MSFT marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
SteveL-MSFT marked this conversation as resolved.
Show resolved
Hide resolved
SteveL-MSFT marked this conversation as resolved.
Show resolved
Hide resolved
|
||
### Listing installed resources | ||
|
||
`Get-PSResource` will list all installed resources with new `Type` column. | ||
|
||
```output | ||
Version Name Type Repository Description | ||
------- ---- ---- ---------- ----------- | ||
5.0.0 VSTeam Module PSGallery Adds functionality for working with Visual … | ||
0.14.94 PSGitHub Module PSGallery This PowerShell module enables integration … | ||
0.7.3 posh-git Module PSGallery Provides prompt with Git status summary … | ||
1.0.1 PSAutoMute Script PSGallery Powershell script to Auto Mute you sound devices … | ||
``` | ||
|
||
SteveL-MSFT marked this conversation as resolved.
Show resolved
Hide resolved
SteveL-MSFT marked this conversation as resolved.
Show resolved
Hide resolved
|
||
## Alternate Proposals and Considerations | ||
|
||
This RFC does not cover the module authoring experience on publishing a cross-platform | ||
module with multiple dependencies and supporting multiple runtimes. | ||
SteveL-MSFT marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
If there is a desire to explicitly update the local cache (like `apt`), we can introduce a | ||
`Update-PSResourceCache` cmdlet with property on a PSRepository indicating whether | ||
SteveL-MSFT marked this conversation as resolved.
Show resolved
Hide resolved
|
||
it auto-updates or not. | ||
This would not be a breaking change. |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.