rfb: Getting several values out of a PowerShell script
The whole “MSBuild without XML“ started with the FubuMVC project using ruby for building. It quickly became apparent that one major omission of MSBuild is the lack of ability of adding “ad-hoc” code to it. Which is why MSBuild was married to PowerShell in the previous post on this series.
of which “gitnumber” and “commit” are used later on.
Now, doing something like the above in PowerShell isn’t that difficult, but I didn’t know at first how to get two values back to MSBuild from a single script, until I remembered the following construct in PowerShell.
It turns out that PowerShell constructs a Hashtable instance from the first line and then provides some syntax sugar to access the key-value pairs with a dot-notation. Armed with this knowledge I could teach rfb to support the following script:
Some people may see it as a hack to use an item group for getting a single line, however the item group has the notion of metadata which allows for a dot-notation to access several values, which makes it a nice container to retrieve numerous values from a single PowerShell script.