This topic contains 4 replies, has 2 voices, and was last updated by
March 12, 2015 at 1:18 am #23255
I started looking at the class based dsc resources in WMF 5 and as a developer they really make more sense to me than the old way. But now that there are attributes and things for DSC resrouces, does that mean that i can also write them in c# like i would a cmdlet?
i also tried to find them in the System.Management.Automation assembly but i didnät find it and i think i didn't look in the right one either, when you install the WMF5 package, were does the WMF5 version of file end up?
March 12, 2015 at 6:26 am #23262KeymasterPoints: 2Rank: Member
You could always write resources in C#; the File resource was. But it's not precisely like a cmdlet. I'm not sure Microsoft has released the reference assemblies yet – those were never part of WMF, they were part of the Windows SDK.
March 12, 2015 at 6:42 am #23266
Right, but as far as i understand you have to do it by writing the three cmd-lets and muck around with the schema file as described here: http://blogs.msdn.com/b/powershell/archive/2014/05/29/wish-i-can-author-dsc-resource-in-c.aspx
but i was hoping that now where resources can be written with classes using something that looks an awful lot like c# attributes, there would be an easier way 🙂
i just basically want to make a c# class and put some attributes on it to make powershell see it as a resource
March 12, 2015 at 6:55 am #23268KeymasterPoints: 2Rank: Member
Yeah, a resource consists of three cmdlets. But they have to meet a special signature. In a DLL module, cmdlets have always been methods of a class, so that doesn't really change. You could write a resource in C# in WMF4, so the class support added to PowerShell's scripting language doesn't really change that. Microsoft just hasn't really documented it, because their focus has been on script-based resources.
You'll definitely be able to write them in C#... but you might have to wait until WM5 actually makes it out of preview. Right now, the code is changing pretty significantly between builds, and the C# scenario isn't one MS is putting a lot of public focus on. Keep in mind that WM5 is at least several months out, and may not release until 2016 if it's held for Windows Server v.Next.
So... patience, padawan.
March 12, 2015 at 7:37 am #23275
I made a connect issue to track this feature
Just to be clear, what i'd like is to write a class in c# and put some attributes on it, pretty much what you'd do with a DSC class resource in powershell, and then not have to deal with mof schema and all that. so, a dsc class resource, but in c# 🙂
What seems to be missing right now is the attributes that are used in the powershell class case (i'm not even sure they are .net attributes but it seems reasonable) as well as the ability for powershell to discover them
i know it's early days, but i really like where WMF5 is going, just hope they will also enable all this new stuff for .net devs as well 🙂
The topic ‘WMF5 DSC class resources in c#’ is closed to new replies.