Skip to content

Publish guidance for existing PS modules #1909

Closed

Description

I have an assembly-based power shell module (pshosts) that I'd like to port to ps-core.

Obviously my first steps are going to be compiling the assembly for .net core, but I'm at a loss for what needs to be done for the module declaration. For example, does ps-core define any additional psm1 syntax for specifying supported platforms or having separate assemblies for full vs core clrs?

I realise its early days right now, but any help would be appreciated.

Activity

  1. added
    Issue-Question
    on Aug 18, 2016
  2. kilasuit commented on Aug 18, 2016

    @kilasuit
    Collaborator

    as of PS 5.1 (avail in win10 & will be in Server 2016) there is an additional property available in the PowerShell Module Manifests called CompatiblePSEditions

    This currently supports Desktop & Core as the possible options and I believe that the PSScriptAnalyzer has been updated to be able to scan for this.

    However

    As soon as you add that the module is unable to be installed on downlevel PS versions like PSv2 - PSv5 (currently)

    I know this is something that myself and other MVP's have been discussing in the last few days.

    But I would be doing what you are suggesting and trying to recompile for .NET core anyway as that should still run on .NET Full versions (note should because I'm not 100% on that)

  3. richardszalay commented on Aug 18, 2016

    @richardszalay
    Author

    Hrm, dropping support for PSv3-5 would be a deal breaker for me, I think, especially since I already distribute via the psgallery so I wouldn't be able to split it via distribution channel. Are there any plans for that to change? (you did say "currently")

    Still, in the meantime I'll look at getting it working under pscore so I'm ready when things change (or those versions become irrelevant - if you know anyone on the psgallery side of things, tell them that OS/PSversion download statistics would be handy :)

  4. kilasuit commented on Aug 18, 2016

    @kilasuit
    Collaborator

    I'd need to dig out some notes but yes this as it is currently. Plans around how this works going forward are still tbd I believe

  5. richardszalay commented on Aug 19, 2016

    @richardszalay
    Author

    No problems, at least I'll be prepared.

  6. Jaykul commented on Aug 20, 2016

    @Jaykul
    Contributor

    Isn't this as good a place as anywhere to discuss this? Ryan Yates (@kilasuit), Kirk Munro (@KirkMunro) Keith Hill (@rkeithhill)

    Obviously PSEdition = Core is not required to get the module to load, and cannot be used without breaking backwards compatibility anyway.

    The problem

    1. You need to ship one module because the PowerShellGallery doesn't currently handle having multiple architecture-specific versions of assemblies.
    2. You need to load the right assembly at run time

    Solution Ideas

    1. Fix it at install time: Fix the PowerShellGallery and the module to be able to publish multiple modules based on the PSEdition and/or PSVersion, and download the right version automatically, or the specified version on demand, or all versions.
    2. Fix it at load time: Decide on a convention (probably just use the same convention that NuGet uses right?) and make Add-Type -Assembly and RequiredAssemblies and also RootModule to load the right assembly automatically.
  7. gigi81 commented on Aug 20, 2016

    @gigi81

    I tried to port one of my assembly based ps modules to ps core on Linux and managed to make it work. I have the same issue as Richard Szalay (@richardszalay) pointed out on how to publish the module to the psgallery so I would as well appreciate any suggestion.

    If I can add to the conversation a secondary issue I experienced is that when I build the module (dll) in the dotnet core project, the nuget dependencies are not copied to the output folder. My understanding is that this is by dotnet core design, and there is no way around it. Dependencies are only copied to the output directory when publishing a command line executable. So, just for the sake of testing, I copied the dependencies manually. Some of the dependencies were actually not required (like all the System.* that are already loaded by the powershell assembly), so I also add to remove the redundant dependencies. This makes the task of packaging the resource quite painful.
    It would be nice if somehow the dependencies could be installed directly from nuget when installing the package. Maybe adding the dependency list on the module manifest.

  8. added this to the milestone on Sep 29, 2016
  9. richardszalay commented on Dec 3, 2016

    @richardszalay
    Author

    Any updates on this? I've seen .NetCore module suffix from the Azure and AWS teams. Google Cloud doesn't publish to the PS Gallery so they simply provide a separate download.

    I'd be happy if that were the guidance, but I'd also be happy with any official guidance.

    (as a reminder, this is the scenario where I'd like to retain compatibility with PowerShell 3 while also supporting PsCore)

  10. richardszalay commented on Dec 4, 2016

    @richardszalay
    Author

    ... or is this one of those things that will be a non-issue with netcore 2.0?

  11. Jaykul commented on Jan 14, 2017

    @Jaykul
    Contributor

    For what it's worth, a binary module can be constructed now targeting .Net Standard 1.6 that will work just fine in full Windows PowerShell with Full Framework as well as PowerShell Core. If you don't need to add functionality per OS, there shouldn't be any need to do anything tricky.

  12. richardszalay commented on Jan 14, 2017

    @richardszalay
    Author

    Thanks Jaykul,

    Does this apply to a specific version of PSCore?

    Also does this mean no longer having to make a change to the manifest (thereby losing support for PS < 5) to support PSCore?

  13. SteveL-MSFT commented on Mar 6, 2017

    @SteveL-MSFT
    Member

    Richard Szalay (@richardszalay) this PR #3095 has documentation on producing portable modules that work on both Windows PowerShell and PowerShell Core

  14. modified the milestones: , on May 24, 2017
  15. modified the milestones: 6.0.0-GA, on Jan 11, 2018
  16. modified the milestones: , Future on Jun 21, 2018
  17. SteveL-MSFT commented on Mar 28, 2019

    @SteveL-MSFT
    Member
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Area-Maintainers-DocumentationIssue-QuestionResolution-Fixed

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions