PoshCode / ModuleBuilder

A PowerShell Module to help scripters write, version, sign, package, and publish.
MIT License
445 stars 54 forks source link

Add support to order PS1 when file system doesn't #118

Closed gaelcolas closed 1 year ago

gaelcolas commented 1 year ago

On Azure DevOps (ubuntu-latest MSFT hosted agents) the PowerShell lists the files in order but not the subfolders (at least not always). This creates psm1 that are unparseable for pwsh because the Class definition is not in order (inherited class defined before parent). This happens when classes/ folder is further divided in subfolders (DSC Resources, GC Resources, Category1, Category2...). image

Question, can we have a "custom sorter"?

Jaykul commented 1 year ago

Well, I think you could list each subfolder in SourceDirectories in order, and it would work..

Currently, that code looks like:

Get-ChildItem -Path @($ModuleInfo.SourceDirectories).ForEach{ Join-Path $ModuleInfo.ModuleBase $_ } -Filter *.ps1 -Recurse -ErrorAction SilentlyContinue

I guess we could add | Sort-Object Fullname and that would take care of it?

gaelcolas commented 1 year ago

Draft PR coming in shortly... :) The question will be, shall we mandate the sorting (as per your example), or leave the user to provide the -Property to Sort-Object...

gaelcolas commented 1 year ago

Completed a while ago.