Proper Naming Convention and Structure for Class-Based Resource Kit

This topic contains 2 replies, has 2 voices, and was last updated by Profile photo of Ryan Spletzer Ryan Spletzer 1 year, 5 months ago.

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
  • #24950
    Profile photo of Ryan Spletzer
    Ryan Spletzer

    I've started writing a DSC Resource, just to automate something small (Get-/Set-NetConnectionProfile) and decided to go the class-based route as this seems cleaner / easier.

    Couple of questions:

    [b]1. [/b]With non-class-based, traditional DSC Resources, there was a very defined structure that you put the files in for packing up in a module. (You only have to look at any of the MSFT_* in the Modules area to see what that structure is like.) You would have one module that contains multiple DSC Resources under the 'DSCResources' folder.) However, when it comes to class-based resources, the only examples I've ever seen on the web and in the MVA courses are just 1 DSC Resource, i.e. just one .psd1 file and one .psm1 file that contains the actual resource class.

    If you wanted to have multiple class-based DSC Resources per module, would you stick all the classes in the root module .psm1 file? Or would you just nest them like you did before under DSCResources (or whatever folder) and dot-source reference them in the root .psm1 file by doing something like:

    . $PSScriptRoot\DSCResources\Company_MyResource1\Company_MyResource1.ps1
    . $PSScriptRoot\DSCResources\Company_MyResource2\Company_MyResource2.ps1

    [b]2. [/b]As far as naming conventions go, they were very laid out with the traditional DSC Resources, but with the class-based resources I haven't seen any examples using the Company_* convention in folder names, file names or class names. Are guidelines around class-based naming conventions different than that of traditional DSC Resources?

    Searched around online quite a bit for some best practices / guidelines around the above, but not finding much thought I would bring it to the forum. Thanks.

    Profile photo of Don Jones
    Don Jones

    Correct – class based resources live In a root module, which is different from v4 resources. All the classes go in a single module.

    Naming conventions are whatever works for you – and the Company_ is still good. That applies to the class names.

    But keep in mind that you're talking about stuff that hasn't shipped and isn't production. It's a little early to start speculating on practices and patterns, yet 🙂

    Profile photo of Ryan Spletzer
    Ryan Spletzer

    Great, thanks Don! Even though it's still early it's nice to have something to aim for. 🙂

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.