Replace hashtable in file (using AST?)

New-ModuleManifest sadly seems to have issues adding nested hashtables to the PrivateData table. To work around this I need to replace the “corrupted” tables in the output.

My module manifest looks like this:

PrivateData = @{ PSData = @{ # Tags applied to this module. These help with module discovery in online galleries. # Tags = @() # A URL to the license for this module. # LicenseUri = '' # A URL to the main website for this project. # ProjectUri = '' # A URL to an icon representing this module. # IconUri = '' # ReleaseNotes of this module # ReleaseNotes = '' } # End of PSData hashtable # CoolSettings CoolSettings = 'System.Collections.Hashtable' } # End of PrivateData hashtable 

But my custom entry should look like this:

# CoolSettings CoolSettings = @{ 1CoolKey = '1CoolValue' 2CoolKey = '2CoolValue' } 

I’m hoping this can be done using AST as this would make analyzing my manifest files a lot easier, but I haven’t found a way to actually modify the output I generate parsing my manifests using the [System.Management.Automation.Language.Parser].

Anyone got an idea how this could be done? 🙂

submitted by /u/PillOfLuck
[link] [comments]

Leave a Reply