Skip to content

Commit bd91dfd

Browse files
committed
Fix GUID and Version in ConvertTo-Script output
1 parent 802604e commit bd91dfd

File tree

2 files changed

+31
-32
lines changed

2 files changed

+31
-32
lines changed

Source/Public/Build-Module.ps1

Lines changed: 30 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Source/Public/ConvertTo-Script.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ function ConvertTo-Script {
8585
@"
8686
<#PSScriptInfo
8787
.VERSION 0.0.0
88-
.GUID $([guid]::newguid())
88+
.GUID $Guid
8989
.AUTHOR anonymous
9090
.COMPANYNAME
9191
.COPYRIGHT

0 commit comments

Comments
 (0)