gaelcolas / Sampler

Module template with build pipeline and examples, including DSC elements.
MIT License
171 stars 42 forks source link

Add Microsoft.PowerShell.PlatyPS module #497

Open Gijsreyn opened 2 weeks ago

Gijsreyn commented 2 weeks ago

Problem description

With the preview release of Microsoft.PowerShell.PlatyPS, it would be great to include it in the RequiredModules.psd1 and move the task logic to use the new commands.

Verbose logs

N/A

How to reproduce

N/A

Expected behavior

Use Microsoft.PowerShell.PlatyPS.

Current behavior

Uses PlatyPS

Suggested solution

Change the RequiredModules.psd1 to include the module. Update the relevant doc tasks.

Operating system the target node is running

N/A

PowerShell version and build the target node is running

N/A

Module version used

N/A
johlju commented 2 weeks ago

It is probably DscResource.DocGenerator tasks that need to be refactored. Are the tasks that runs PlatyPS in Sampler used by anyone?

Gijsreyn commented 2 weeks ago

I still use this one: https://github.com/gaelcolas/Sampler/blob/main/.build/tasks/generateHelp.PlatyPS.build.ps1. If you want, I can take a look and rewrite it.

johlju commented 2 weeks ago

How much refactor will be needed? Thinking if there gonna be any breaking changes πŸ€” But please send in a PR 😊

Gijsreyn commented 2 weeks ago

Tbh, I already wanted to write some code, but spend my time around the winget-dsc area. At least it gave me some thoughts.

The new Microsoft.PowerShell.PlatyPS has new cmdlets. I wanted to introduce a new task, say something like: generateHelp.MSPlatyPS.build.ps1. New cmdlets will be added in here. The challenging part is mostly on the dlls loaded in the background. I think both use YamlDotnet or some other variant. If you install both, assembly loading will fail. I don't know how much modules use the task, but simply replacing PlatyPS in the RequiredModules.psd1 with the new one - would do the trick.

johlju commented 2 weeks ago

That problem already exist with the current PlatyPS and is solved by running PlatyPS in a separate session so it is the only module using the dlls. Might need to do the same with this new module.

Gijsreyn commented 2 weeks ago

Do you mind sharing an example Johan? I tried searching for it, but couldn't find it :(

johlju commented 2 weeks ago

It’s in the existing task https://github.com/gaelcolas/Sampler/blob/1e3176678f2ab6f74286ca294155f1de343ac4ef/.build/tasks/generateHelp.PlatyPS.build.ps1#L92

Gijsreyn commented 2 weeks ago

Clearly I wasn't watching with my eyes, thanks Johan.

johlju commented 2 weeks ago

Also, if you adding a new task, maybe look at DscResource.DocGenerator module and those tasks that generate help for public commands and external help and see if we should remove tasks there that will be covered by any changes here.

Gijsreyn commented 1 week ago

@johlju Unfortunately, I stumbled on a barrier. I opened a issue at PlatyPS repository. If you have any suggestions in the meantime to proceed further and see the impact of the change, please give me a shout :)

johlju commented 1 week ago

Is it the parameter HelpVersion that is the issue? If so I suggest just setting it to the full version stripping the prerelease string, and if there is a change in the future for that property we can just remove the part that stripping prerelease string. πŸ€”