Skip to content
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

Current module manifest schema is not adequate to properly support cross-platform modules #5541

Closed
rkeithhill opened this issue Nov 25, 2017 · 9 comments
Labels
Issue-Discussion the issue may not have a clear classification yet. The issue may generate an RFC or may be reclassif Resolution-No Activity Issue has had no activity for 6 months or more WG-Cmdlets-Core cmdlets in the Microsoft.PowerShell.Core module

Comments

@rkeithhill
Copy link
Collaborator

rkeithhill commented Nov 25, 2017

It is not going to be uncommon for module authors to want to provide slightly different functionality on different operating systems e.g. the module provides 30 commands, two of which only work on Windows PowerShell. Right now, there is no good way to declare "conditional" module exports in the manifest where the condition is the OS platform.

In fact, even PowerShellVersion is problematic if you design your module to load into both Windows PowerShell and PowerShell Core. Which PowerShell version does that refer to? Windows PowerShell? PowerShell Core? What if at some point, on PS Core I require 6.1.0? Does that mean my module can't load into Windows PowerShell 5.x anymore - probably. But I may not be providing that functionality when I'm loaded into Windows PowerShell (runtime decision) so Win PS 5.1 should be allowed when loading into Windows PowerShell.

AFAICT all of these field's values may be conditional upon the OS platform and/or the PowerShell platform (Win or Core)

  • PowerShellVersion
  • PowerShellHostName / Version
  • RequiredAssemblies
  • RequiredModules
  • ModuleList
  • NestedModules
  • FormatsToProcess
  • ScriptsToProcess
  • TypesToProcess
  • ClrVersion
  • DotNetFrameworkVersion
  • AliasesToExport although CompatiblePSEditions might mitigate this one
  • CmdletsToExport
  • FunctionsToExport
  • VariablesToExport
  • Tags

In order to make any changes backwards compatible with existing Windows PowerShell instance, we could put all the conditional declarations in PrivateData. This implies that fields not in PrivateData inherently apply to Windows PowerShell when module is loaded by Windows PowerShell. PowerShell Core could be modified to process the conditional fields in PrivateData. What might those look like? Maybe this?

    PrivateData = @{
        PSManifestEx = @{
            PowerShellVersion = "6.1.0" # fields at this level apply to all OS platforms for PS Core
            Linux = @{
                RequiredModules = @(...)
                CmdletsToExport = @(...)
            }
            MacOS = @{
                RequiredModules = @(...)
                CmdletsToExport = @(...)
            }
            Windows = @{ # this is for PowerShell Core on Windows
                RequiredModules = @(...)
                CmdletsToExport = @(...)
            }
        }

This doesn't take into account Nano server which I don't have enough experience with to take it into account. Anyway, this is just something to get the conversation started.

Long term, this approach seems less than ideal - burying so much important metadata under PrivateData.

@lzybkr
Copy link
Member

lzybkr commented Nov 25, 2017

I originally proposed allowing variables like $IsLinux in the module manifest so you could write:

ExportedCmdlets = @(
    'Get-Thing'
    if ($IsLinux) { 'Get-LinuxThing' }
)

Untested, but I think all that is needed is to add to this list.

@iSazonov iSazonov added WG-Cmdlets-Core cmdlets in the Microsoft.PowerShell.Core module Issue-Discussion the issue may not have a clear classification yet. The issue may generate an RFC or may be reclassif labels Nov 25, 2017
@mklement0
Copy link
Contributor

mklement0 commented Mar 8, 2018

A complementary aspect is how to restrict a module to an edition / a (set of) platform(s):

  • From what I can tell, setting CompatiblePSEditions to one edition isn't being enforced at module import time.

  • It seems that there is no key at all to limit support to a given (set of) platform(s).

(Note that edition support and platform support are independent dimensions; conceivably, modules can run on both editions while requiring Windows as the platform.
Conversely, though, limiting support to non-Windows platforms implies the Core edition.)

@fMichaleczek
Copy link

I would like to contribute and make a PR for this issue :

Anything else ?

@vexx32
Copy link
Collaborator

vexx32 commented Apr 17, 2019

That sounds like a good start, go for it! 😄

@fMichaleczek
Copy link

fMichaleczek commented May 1, 2019

I would like to add PSVersionTable too, someone against that ?
Architecture is still a missing information in PSVersionTable but can be added later #8047

Copy link
Contributor

This issue has not had any activity in 6 months, if this is a bug please try to reproduce on the latest version of PowerShell and reopen a new issue and reference this issue if this is still a blocker for you.

1 similar comment
Copy link
Contributor

This issue has not had any activity in 6 months, if this is a bug please try to reproduce on the latest version of PowerShell and reopen a new issue and reference this issue if this is still a blocker for you.

@microsoft-github-policy-service microsoft-github-policy-service bot added Resolution-No Activity Issue has had no activity for 6 months or more labels Nov 16, 2023
Copy link
Contributor

This issue has not had any activity in 6 months, if this is a bug please try to reproduce on the latest version of PowerShell and reopen a new issue and reference this issue if this is still a blocker for you.

Copy link
Contributor

This issue has been marked as "No Activity" as there has been no activity for 6 months. It has been closed for housekeeping purposes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Issue-Discussion the issue may not have a clear classification yet. The issue may generate an RFC or may be reclassif Resolution-No Activity Issue has had no activity for 6 months or more WG-Cmdlets-Core cmdlets in the Microsoft.PowerShell.Core module
Projects
None yet
Development

No branches or pull requests

6 participants