May 4, 2015 at 6:09 pm #24950
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:
[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.
May 6, 2015 at 6:25 am #24985
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 🙂
May 10, 2015 at 3:30 pm #25063
Great, thanks Don! Even though it's still early it's nice to have something to aim for. 🙂
You must be logged in to reply to this topic.