Sunday, May 19, 2024
HomePowershellPublishing PSTimeSheets To The PSGallery – No Column Identify

Publishing PSTimeSheets To The PSGallery – No Column Identify


Phrases: 567

Time to learn: ~ 3 minutes

Skip This for Your Sanity

I’ve created a module
trigger no one needs to do timesheets no extra;
they need PowerShell to do it for ya.
Effectively, if that is what you want,
then that is what I’ll give ya.
(Ahem, apologies about that, songs get caught in my head generally).

I Confess

I’ve labored with PowerShell for years however have by no means revealed a module earlier than. I’ve helped write adjustments to a couple, e.g. dbatools, dbachecks, and some inside ones.

However the precise creating and publishing one wants including to my expertise checklist.

There was plenty of gnashing of the tooth, wailing of the cries, and studying of the documentation.

There have been a couple of issues that I wished to do earlier than I revealed.

Creating exams in opposition to all of the capabilities; performed.
Creating documentation for all of the capabilities; performed.

These have been the straightforward sections; publishing the module was the place I encountered the speedbumps.

So right here’s a fast checklist of the elements that threw me for a loop.

.PSD1 vs .PSM1 Recordsdata

I’m conscious that the auto-loading of PowerShell modules boils all the way down to a mix of the PSModulePath setting variable ($ENV:PSModulePath) and the .psm1 file for the module. However is there a default solution to auto-generate that file?

I assumed it was utilizing the New-Module Manifest command, however nope, that creates the .psd1 file. At the very least I don’t have to fret about that.

One of the best apply is to not auto-load every little thing into the .psm1 file. It’s purported to be extra performant to re-create the capabilities’ definitions there. That’s not what I did.

Publishing

To begin with, sure. Anybody can publish to the PSGallery – you want an account.

Did I do know that you simply wanted an account? Hell no.
Did I discover out? Hell yeah.

To be truthful, they are saying as a lot if you attempt to publish the module, asking you for a NuGetApiKey. Pop open your profile in PSGallery, and you’ll generate it from there.

Lacking Values within the .PSD1 File

Keep in mind a couple of paragraphs in the past after I stated I didn’t have to fret concerning the .psd1 file? Yeah, I used to be improper. The command New-ModuleManifest is great. However, a couple of key options get missed from the default choices.

The Description subject doesn’t have an entry, but it’s a required key to publish a module. Easy sufficient to open a textual content editor and replace the values there; easy, if annoying.

This subsequent bit is on me: after you might have stuffed out the outline subject and tried to publish the module, you’ll get the identical error message. That’s as a result of the outline subject, beginning off empty, may even be a remark. Re-open the editor, take away the hash/pound/octothorp that makes the sector a remark, save, and you need to be good to go.

NodeJS, I Suppose?

There have been different tangles with the Publish-Module command that pushes to the PSGallery. I’ve chalked them all the way down to a sinister mixture.

The Linux information wanted for troubleshooting vs the quantity of Linux information I had.

I switched out of my WSL and tried to publish from my Home windows Desktop. It went as easy as… a really easy factor.

Return 0

General, it was a easy course of made tougher attributable to lack of expertise. Straightforward sufficient for anybody to choose up, annoying however unmanageable. Would I do it once more?

Effectively, I’ve received enhancements to make to PSTimeSheets, so… yeah!

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments