Creating PowerShell module via .NET class library

I am building a PowerShell module in .NET. I’ve read somewhere that PowerShell 3.0 targets .NET Framework 4.0 and so my class library project must also be targeting the same version. My problem is I have existing projects that are targeting .NET Framework 4.5 and referencing them in my powershell module class library project using .NET 4.0 does not work, it does not see those project references unless they are the same version. Is there a way around this or is PowerShell going to target .NET 4.5 soon? Changing the .NET Framework version of my existing projects is not an option for me right now. Any suggestions?

You can have your PowerShell module target .NET 4.5. Just make sure your module manifest reflects this in its CLRVersion property.

Also, in the opposite direction, if you’re writing a module that is compatible with PowerShell v2.0, then it’s fine for you to compile it once using .NET 2.0, 3.0 or 3.5 (all valid for PowerShell 2.0), and the module should still run just fine when imported in PS v3 or later, as far as I know. When I distribute GitHub - dlwyatt/PowerShellLoggingModule: Automatically capture and save PowerShell console output from a script (without the limitations and headaches of Start-Transcript) , I don’t compile it multiple times for different frameworks, and I’ve never had any complaints about it not working in later PS versions.

Thanks Dave!