views:

172

answers:

1

How do I build a PowerShell snap-in to target PowerShell v1 and v2? Given that v1 and v2 can't be installed side by side how can I reference the appropriate assemblies and build against them?

Inevitably as things go on I'm going to be adding new PowerShell v2 specific features. So I'm going to need separate product builds targeting different versions of PowerShell.

+2  A: 

We do that with the PowerShell Community Extensions 1.2. We just reference the PowerShell 1.0 version of System.Management.Automation but AFAICT there is only a 1.0 version of this assembly. Anyway, the snapin loads and runs fine in both PowerShell 1.0 and 2.0.

Keith Hill
Yeah, I've tested my 1.0 snap-in and it runs fine on 2.0. I just wondered if when we start using 2.0 only features how I'm going to cope.Thanks for the info.
Jack Hughes
As a matter of interest, how do you package for 64 bit and 32 bit Powershell? We use universal binaries which work fine on both 32 bit and 64 bit Windows. DO you install your snapin inside both Program Files and PRogram Files (x86)? I can't see any other way to do it other than to duplicate the install in two places?
Jack Hughes
We install only to the Program Files (x86) location but we installutil for both 32-bit and 64-bit. IIRC the MSI installer handles 32-bit registration and for 64-bit I think we have a custom action that uses the 64-bit installutil.exe to register the snapin.
Keith Hill