@@ -217,37 +217,7 @@ function Build-Module {
217217 # We have to force the Encoding to string because PowerShell Core made up encodings
218218 SetModuleContent - Source (@ ($ModuleInfo.Prefix ) + $AllScripts.FullName + @ ($ModuleInfo.Suffix )).Where { $_ } - Output $RootModule - Encoding " $ ( $ModuleInfo.Encoding ) "
219219
220- # Make sure Generators has (only one copy of) our built-in mandatory ones
221- # Move-UsingStatement always comes first, in hopes there will not be any parse errors afterward
222- $MoveUsing = @ { Generator = " Move-UsingStatement" }
223- # Update-AliasesToExport always comes last, in case the other generators add aliases
224- $UpdateAlias = @ { Generator = " Update-AliasesToExport" ; ModuleManifest = $OutputManifest }
225- if (! $ModuleInfo.Generators ) {
226- $ModuleInfo = $ModuleInfo | Update-Object @ { Generators = $MoveUsing , $UpdateAlias }
227- } else {
228-
229- if ($Custom = $ModuleInfo.Generators.Where { $_.Generator -eq " Move-UsingStatement" }) {
230- $MoveUsing = $Custom
231- $ModuleInfo.Generators = $ModuleInfo.Generators.Where { $_.Generator -ne " Move-UsingStatement" }
232- }
233-
234- if ($Custom = $ModuleInfo.Generators.Where { $_.Generator -eq " Update-AliasesToExport" }) {
235- $UpdateAlias = $Custom
236- $ModuleInfo.Generators = $ModuleInfo.Generators.Where { $_.Generator -ne " Update-AliasesToExportUpdate-AliasesToExport" }
237- }
238- $ModuleInfo.Generators = @ ($MoveUsing ) + @ ($ModuleInfo.Generators ) + @ ($UpdateAlias )
239- }
240-
241- # By explicitly converting, we support wildcards in the BoilerplateDirectory parameter
242- $BoilerplateDirectory = @ ($ModuleInfo.BoilerplateDirectory ).ForEach {
243- Join-Path - Path $ModuleInfo.ModuleBase - ChildPath $_ | Convert-Path - ErrorAction SilentlyContinue
244- }
245-
246- $ModuleInfo.Generators | Invoke-ScriptGenerator - Path $RootModule - Overwrite
247-
248- # $ParseResult = ConvertToAst $RootModule
249- # $ParseResult | MoveUsingStatement -Encoding "$($ModuleInfo.Encoding)"
250-
220+ # Update the module manifest (before generators)
251221 # If there is a PublicFilter, update ExportedFunctions
252222 if ($ModuleInfo.PublicFilter ) {
253223 # SilentlyContinue because there don't *HAVE* to be public functions
@@ -303,6 +273,35 @@ function Build-Module {
303273 }
304274 }
305275
276+ # Make sure Generators has (only one copy of) our built-in mandatory ones
277+ # Move-UsingStatement always comes first, in hopes there will not be any parse errors afterward
278+ $MoveUsing = @ { Generator = " Move-UsingStatement" }
279+ # Update-AliasesToExport always comes last, in case the other generators add aliases
280+ $UpdateAlias = @ { Generator = " Update-AliasesToExport" ; ModuleManifest = $OutputManifest }
281+ if (! $ModuleInfo.Generators ) {
282+ $ModuleInfo = $ModuleInfo | Update-Object @ { Generators = $MoveUsing , $UpdateAlias }
283+ } else {
284+
285+ if ($Custom = $ModuleInfo.Generators.Where { $_.Generator -eq " Move-UsingStatement" }) {
286+ $MoveUsing = $Custom
287+ $ModuleInfo.Generators = $ModuleInfo.Generators.Where { $_.Generator -ne " Move-UsingStatement" }
288+ }
289+
290+ if ($Custom = $ModuleInfo.Generators.Where { $_.Generator -eq " Update-AliasesToExport" }) {
291+ $UpdateAlias = $Custom
292+ $ModuleInfo.Generators = $ModuleInfo.Generators.Where { $_.Generator -ne " Update-AliasesToExportUpdate-AliasesToExport" }
293+ }
294+ $ModuleInfo.Generators = @ ($MoveUsing ) + @ ($ModuleInfo.Generators ) + @ ($UpdateAlias )
295+ }
296+
297+ # By explicitly converting, we support wildcards in the BoilerplateDirectory parameter
298+ $BoilerplateDirectory = @ ($ModuleInfo.BoilerplateDirectory ).ForEach {
299+ Join-Path - Path $ModuleInfo.ModuleBase - ChildPath $_ | Convert-Path - ErrorAction SilentlyContinue
300+ }
301+
302+ $ModuleInfo.Generators | Invoke-ScriptGenerator - Path $RootModule - Overwrite
303+
304+
306305 # This is mostly for testing ...
307306 if ($ModuleInfo.Passthru ) {
308307 Get-Module $OutputManifest - ListAvailable
0 commit comments