/// <summary> /// Verify minClientVersion. /// </summary> public static bool IsMinClientVersionCompatible(NuspecCoreReaderBase nuspecReader) { if (nuspecReader == null) { throw new ArgumentNullException(nameof(nuspecReader)); } // Read the minClientVersion from the nuspec, this may be null var packageMinClientVersion = nuspecReader.GetMinClientVersion(); return(packageMinClientVersion == null || IsMinClientVersionCompatible(packageMinClientVersion)); }
/// <summary> /// Check the package minClientVersion and throw if it is greater than the current client version. /// </summary> public static void VerifyMinClientVersion(NuspecCoreReaderBase nuspecReader) { if (nuspecReader == null) { throw new ArgumentNullException(nameof(nuspecReader)); } if (!IsMinClientVersionCompatible(nuspecReader)) { var packageIdentity = nuspecReader.GetIdentity(); var packageMinClientVersion = nuspecReader.GetMinClientVersion(); var clientVersion = GetNuGetClientVersion(); throw new MinClientVersionException( string.Format(CultureInfo.CurrentCulture, Strings.PackageMinVersionNotSatisfied, packageIdentity.Id + " " + packageIdentity.Version.ToNormalizedString(), packageMinClientVersion.ToNormalizedString(), clientVersion.ToNormalizedString())); } }