Exemplo n.º 1
0
        // Static Constructor.
        static PSVersionInfo()
        {
            s_psVersionTable = new PSVersionHashTable(StringComparer.OrdinalIgnoreCase);

            s_psVersionTable[PSVersionInfo.PSVersionName]                 = s_psV6Version;
            s_psVersionTable[PSVersionInfo.PSEditionName]                 = PSEditionValue;
            s_psVersionTable[PSGitCommitIdName]                           = GetCommitInfo();
            s_psVersionTable[PSCompatibleVersionsName]                    = new Version[] { s_psV1Version, s_psV2Version, s_psV3Version, s_psV4Version, s_psV5Version, s_psV51Version, s_psV6Version };
            s_psVersionTable[PSVersionInfo.SerializationVersionName]      = new Version(InternalSerializer.DefaultVersion);
            s_psVersionTable[PSVersionInfo.PSRemotingProtocolVersionName] = RemotingConstants.ProtocolVersion;
            s_psVersionTable[PSVersionInfo.WSManStackVersionName]         = GetWSManStackVersion();
            s_psVersionTable[PSPlatformName] = Environment.OSVersion.Platform.ToString();
            s_psVersionTable[PSOSName]       = Runtime.InteropServices.RuntimeInformation.OSDescription.ToString();
        }
Exemplo n.º 2
0
        // Static Constructor.
        static PSVersionInfo()
        {
            s_psVersionTable = new PSVersionHashTable(StringComparer.OrdinalIgnoreCase);

            Assembly currentAssembly = typeof(PSVersionInfo).Assembly;

            ProductVersion = currentAssembly.GetCustomAttribute <AssemblyInformationalVersionAttribute>().InformationalVersion;

            // Get 'GitCommitId' and 'PSVersion' from the 'productVersion' assembly attribute.
            //
            // The strings can be one of the following format examples:
            //    when powershell is built from a commit:
            //      productVersion = '6.0.0-beta.7 Commits: 29 SHA: 52c6b...' convert to GitCommitId = 'v6.0.0-beta.7-29-g52c6b...'
            //                                                                           PSVersion   = '6.0.0-beta.7'
            //    when powershell is built from a release tag:
            //      productVersion = '6.0.0-beta.7 SHA: f1ec9...'             convert to GitCommitId = 'v6.0.0-beta.7'
            //                                                                           PSVersion   = '6.0.0-beta.7'
            //    when powershell is built from a release tag for RTM:
            //      productVersion = '6.0.0 SHA: f1ec9...'                    convert to GitCommitId = 'v6.0.0'
            //                                                                           PSVersion   = '6.0.0'
            string rawGitCommitId;
            string mainVersion = ProductVersion.Substring(0, ProductVersion.IndexOf(' '));

            if (ProductVersion.Contains(" Commits: "))
            {
                rawGitCommitId = ProductVersion.Replace(" Commits: ", "-").Replace(" SHA: ", "-g");
            }
            else
            {
                rawGitCommitId = mainVersion;
            }

            s_psSemVersion = new SemanticVersion(mainVersion);
            s_psVersion    = (Version)s_psSemVersion;

            s_psVersionTable[PSVersionInfo.PSVersionName]                 = s_psSemVersion;
            s_psVersionTable[PSVersionInfo.PSEditionName]                 = PSEditionValue;
            s_psVersionTable[PSGitCommitIdName]                           = rawGitCommitId;
            s_psVersionTable[PSCompatibleVersionsName]                    = new Version[] { s_psV1Version, s_psV2Version, s_psV3Version, s_psV4Version, s_psV5Version, s_psV51Version, s_psV6Version, s_psV61Version, s_psV62Version, s_psV7Version, s_psV71Version, s_psVersion };
            s_psVersionTable[PSVersionInfo.SerializationVersionName]      = new Version(InternalSerializer.DefaultVersion);
            s_psVersionTable[PSVersionInfo.PSRemotingProtocolVersionName] = RemotingConstants.ProtocolVersion;
            s_psVersionTable[PSVersionInfo.WSManStackVersionName]         = GetWSManStackVersion();
            s_psVersionTable[PSPlatformName] = Environment.OSVersion.Platform.ToString();
            s_psVersionTable[PSOSName]       = Runtime.InteropServices.RuntimeInformation.OSDescription;
        }
Exemplo n.º 3
0
        // Static Constructor.
        static PSVersionInfo()
        {
            s_psVersionTable = new PSVersionHashTable(StringComparer.OrdinalIgnoreCase);

            s_psVersionTable[PSVersionInfo.PSVersionName] = s_psV6Version;
            s_psVersionTable["PSEdition"]            = PSEditionValue;
            s_psVersionTable["BuildVersion"]         = GetBuildVersion();
            s_psVersionTable["GitCommitId"]          = GetCommitInfo();
            s_psVersionTable["PSCompatibleVersions"] = new Version[] { s_psV1Version, s_psV2Version, s_psV3Version, s_psV4Version, s_psV5Version, s_psV51Version, s_psV6Version };
            s_psVersionTable[PSVersionInfo.SerializationVersionName]      = new Version(InternalSerializer.DefaultVersion);
            s_psVersionTable[PSVersionInfo.PSRemotingProtocolVersionName] = RemotingConstants.ProtocolVersion;
            s_psVersionTable[PSVersionInfo.WSManStackVersionName]         = GetWSManStackVersion();
#if CORECLR
            s_psVersionTable["CLRVersion"] = null;
#else
            s_psVersionTable["CLRVersion"] = Environment.Version;
#endif
        }