/// <summary>
        /// Checks whether the provided version is consumable by legacy 2.x clients,
        /// which do not support a `.` in release labels, or release labels starting with numeric characters.
        /// See also https://github.com/NuGet/NuGetGallery/issues/3226.
        /// </summary>
        /// <param name="version">The <see cref="NuGetVersion"/> to check for 2.x client compatibility.</param>
        /// <returns>Returns a <see cref="ValidationResult"/> when non-compliant; otherwise <c>null</c>.</returns>
        private static ValidationResult ValidateVersionForLegacyClients(NuGetVersion version)
        {
            if (!version.IsSemVer2 && !version.IsValidVersionForLegacyClients())
            {
                return(new ValidationResult(string.Format(
                                                CultureInfo.CurrentCulture,
                                                CoreStrings.Manifest_InvalidVersion,
                                                version)));
            }

            return(null);
        }
Пример #2
0
        private static ValidationResult ValidateVersion(NuGetVersion version)
        {
            if (version.IsSemVer200())
            {
                return(new ValidationResult(string.Format(
                                                CultureInfo.CurrentCulture,
                                                Strings.Manifest_InvalidVersionSemVer200,
                                                version.ToFullString())));
            }
            else if (!version.IsValidVersionForLegacyClients())
            {
                return(new ValidationResult(string.Format(
                                                CultureInfo.CurrentCulture,
                                                Strings.Manifest_InvalidVersion,
                                                version)));
            }

            return(null);
        }