views:

84

answers:

2

Is there a native or custom MSBuild task available that returns the current OS version? Is there a binary that I could call via an Exec task? Or is there some other option?

Edit: Peter Lang suggested the following link: http://www.paraesthesia.com/archive/2009/07/06/getting-the-windows-os-version-in-msbuild.aspx

+2  A: 

You can try with a registry key lookup as described in this post.

Peter Lang
I did come across that link earlier. I should have put it in the original question. Thanks!
Scott A. Lawrence
+1 for teaching me how to query registry key in msbuild - this might come handy any time.
Filburt
+1  A: 

You could Exec this PowerShell line:

Get-WMIObject Win32_OperatingSystem | select Version
Filburt
I hadn't considered running an Exec of PowerShell before. This looks very interesting. As it turns out, we recently implemented a custom MSBuild task that executes PowerShell scripts.
Scott A. Lawrence
@Scott There's a lot more in this: try ServicePackMajorVersion instead of Version for example
Filburt