internal static NetCoreAppSettings GetCurrentVersion()
        {
            if (RuntimeInformation.IsFullFramework)
            {
                return(Default);
            }

            string netCoreAppVersion;

            try
            {
                netCoreAppVersion = RuntimeInformation.GetNetCoreVersion(); // it might throw on CoreRT
            }
            catch
            {
                return(Default);
            }

            if (string.IsNullOrEmpty(netCoreAppVersion))
            {
                return(Default);
            }

            string version = netCoreAppVersion.Substring(0, 3); // 2.0, 3.1 etc

            return(new NetCoreAppSettings($"netcoreapp{version}", null, $".NET Core {version}"));
        }
        internal static CoreRuntime GetCurrentVersion()
        {
            if (!RuntimeInformation.IsNetCore)
            {
                throw new NotSupportedException("It's impossible to reliably detect the version of .NET Core if the process is not a .NET Core process!");
            }

            string netCoreAppVersion = RuntimeInformation.GetNetCoreVersion();

            if (!string.IsNullOrEmpty(netCoreAppVersion) && Version.TryParse(netCoreAppVersion, out _))
            {
                return(FromNetCoreAppVersion(netCoreAppVersion));
            }

            var coreclrAssemblyInfo = FileVersionInfo.GetVersionInfo(typeof(object).Assembly.Location);

            // coreclrAssemblyInfo.Product*Part properties return 0 so we have to implement some ugly parsing...
            return(FromProductVersion(coreclrAssemblyInfo.ProductVersion, coreclrAssemblyInfo.ProductName));
        }
        internal static NetCoreAppSettings GetCurrentVersion()
        {
            if (RuntimeInformation.IsFullFramework)
            {
                return(Default);
            }

            string netCoreAppVersion = null;

            try
            {
                netCoreAppVersion = RuntimeInformation.GetNetCoreVersion(); // it might throw on CoreRT
            }
            catch
            {
                return(Default);
            }

            if (string.IsNullOrEmpty(netCoreAppVersion))
            {
                return(Default);
            }

            if (netCoreAppVersion.StartsWith("2.0", StringComparison.InvariantCultureIgnoreCase))
            {
                return(NetCoreApp20);
            }
            if (netCoreAppVersion.StartsWith("2.1", StringComparison.InvariantCultureIgnoreCase))
            {
                return(NetCoreApp21);
            }
            if (netCoreAppVersion.StartsWith("2.2", StringComparison.InvariantCultureIgnoreCase))
            {
                return(NetCoreApp22);
            }
            if (netCoreAppVersion.StartsWith("3.0", StringComparison.InvariantCultureIgnoreCase))
            {
                return(NetCoreApp30);
            }

            return(Default);
        }