@@ -34,6 +34,7 @@ public class Helper
34
34
private CommandInvocationIntrinsics invokeCommand ;
35
35
private IOutputWriter outputWriter ;
36
36
private Object getCommandLock = new object ( ) ;
37
+ private readonly static Version minSupportedPSVersion = new Version ( 3 , 0 ) ;
37
38
38
39
#endregion
39
40
@@ -1605,7 +1606,7 @@ public bool GetNamedArgumentAttributeValue(NamedAttributeArgumentAst namedAttrib
1605
1606
/// <summary>
1606
1607
/// Gets valid keys of a PowerShell module manifest file for a given PowerShell version
1607
1608
/// </summary>
1608
- /// <param name="powershellVersion">Version parameter with valid values: 5.0, 4.0 and 3.0</param>
1609
+ /// <param name="powershellVersion">Version parameter; valid if >= 3.0</param>
1609
1610
/// <returns>Returns an enumerator over valid keys</returns>
1610
1611
public static IEnumerable < string > GetModuleManifestKeys ( Version powershellVersion )
1611
1612
{
@@ -1615,7 +1616,7 @@ public static IEnumerable<string> GetModuleManifestKeys(Version powershellVersio
1615
1616
}
1616
1617
if ( ! IsPowerShellVersionSupported ( powershellVersion ) )
1617
1618
{
1618
- throw new ArgumentException ( "Invalid PowerShell version. Choose from 3.0, 4.0 or 5 .0" ) ;
1619
+ throw new ArgumentException ( "Invalid PowerShell version. Choose from version greater than or equal to 3 .0" ) ;
1619
1620
}
1620
1621
var keys = new List < string > ( ) ;
1621
1622
var keysCommon = new List < string > {
@@ -1648,10 +1649,14 @@ public static IEnumerable<string> GetModuleManifestKeys(Version powershellVersio
1648
1649
"HelpInfoURI" ,
1649
1650
"DefaultCommandPrefix" } ;
1650
1651
keys . AddRange ( keysCommon ) ;
1651
- if ( powershellVersion . Major = = 5 )
1652
+ if ( powershellVersion . Major > = 5 )
1652
1653
{
1653
1654
keys . Add ( "DscResourcesToExport" ) ;
1654
1655
}
1656
+ if ( powershellVersion >= new Version ( 5 , 1 ) )
1657
+ {
1658
+ keys . Add ( "CompatiblePSEditions" ) ;
1659
+ }
1655
1660
return keys ;
1656
1661
}
1657
1662
@@ -1689,7 +1694,7 @@ private static Dictionary<string, StatementAst> GetMapFromHashtableAst(Hashtable
1689
1694
/// <summary>
1690
1695
/// Checks if the version is supported
1691
1696
///
1692
- /// PowerShell versions with Major 5, 4 and 3 are supported
1697
+ /// PowerShell versions with Major greater than 3 are supported
1693
1698
/// </summary>
1694
1699
/// <param name="version">PowerShell version</param>
1695
1700
/// <returns>true if the given version is supported else false</returns>
@@ -1699,23 +1704,14 @@ public static bool IsPowerShellVersionSupported(Version version)
1699
1704
{
1700
1705
throw new ArgumentNullException ( "version" ) ;
1701
1706
}
1702
-
1703
- switch ( version . Major )
1704
- {
1705
- case 5 :
1706
- case 4 :
1707
- case 3 :
1708
- return true ;
1709
- default :
1710
- return false ;
1711
- }
1707
+ return version >= minSupportedPSVersion ;
1712
1708
}
1713
1709
1714
1710
/// <summary>
1715
1711
/// Checks if a given file is a valid PowerShell module manifest
1716
1712
/// </summary>
1717
1713
/// <param name="filepath">Path to module manifest</param>
1718
- /// <param name="powershellVersion">Version parameter with valid values: 5.0, 4.0 and 3.0</param>
1714
+ /// <param name="powershellVersion">Version parameter; valid if >= 3.0</param>
1719
1715
/// <returns>true if given filepath points to a module manifest, otherwise false</returns>
1720
1716
public static bool IsModuleManifest ( string filepath , Version powershellVersion = null )
1721
1717
{
@@ -1775,8 +1771,8 @@ public static bool IsModuleManifest(string filepath, Version powershellVersion =
1775
1771
}
1776
1772
else
1777
1773
{
1778
- // default to version 5.0
1779
- allKeys = GetModuleManifestKeys ( new Version ( "5.0 " ) ) ;
1774
+ // default to version 5.1
1775
+ allKeys = GetModuleManifestKeys ( new Version ( "5.1 " ) ) ;
1780
1776
}
1781
1777
}
1782
1778
0 commit comments