本文整理汇总了C#中NuGet.Versioning.NuGetVersion类的典型用法代码示例。如果您正苦于以下问题:C# NuGetVersion类的具体用法?C# NuGetVersion怎么用?C# NuGetVersion使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
NuGetVersion类属于NuGet.Versioning命名空间,在下文中一共展示了NuGetVersion类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: VersionRange
/// <summary>
/// Creates a VersionRange with the given min and max.
/// </summary>
/// <param name="minVersion">Lower bound of the version range.</param>
/// <param name="includeMinVersion">True if minVersion satisfies the condition.</param>
/// <param name="maxVersion">Upper bound of the version range.</param>
/// <param name="includeMaxVersion">True if maxVersion satisfies the condition.</param>
/// <param name="includePrerelease">True if prerelease versions should satisfy the condition.</param>
/// <param name="floatRange">The floating range subset used to find the best version match.</param>
/// <param name="originalString">The original string being parsed to this object.</param>
public VersionRange(NuGetVersion minVersion = null, bool includeMinVersion = true, NuGetVersion maxVersion = null,
bool includeMaxVersion = false, bool? includePrerelease = null, FloatRange floatRange = null, string originalString = null)
: base(minVersion, includeMinVersion, maxVersion, includeMaxVersion, includePrerelease)
{
_floatRange = floatRange;
_originalString = originalString;
}
示例2: VersionLength
public void VersionLength(string version)
{
// Arrange & Act
var semVer = new NuGetVersion(version);
Assert.Equal("2.0.0", semVer.ToNormalizedString());
}
示例3: Process
public void Process(IndexReader indexReader,
string readerName,
int perSegmentDocumentNumber,
int perIndexDocumentNumber,
Document document,
string id,
NuGetVersion version)
{
// main index docid
if (id == null || version == null)
{
return;
}
List<RegistrationEntry> versions;
if (!_registrations.TryGetValue(id, out versions))
{
versions = new List<RegistrationEntry>();
_registrations.Add(id, versions);
}
var entry = new RegistrationEntry(perIndexDocumentNumber, version, GetListed(document));
versions.Add(entry);
}
示例4: IsInstalled
public override bool IsInstalled(string packageId, NuGetVersion packageVersion)
{
NuGetTraceSources.CoreInteropInstalledPackagesList.Verbose("isinstalled", "IsInstalled? {0} {1}", packageId, packageVersion.ToNormalizedString());
return _localRepository.Exists(
packageId,
new SemanticVersion(packageVersion.Version, packageVersion.Release));
}
示例5: Process
public void Process(IndexReader indexReader,
string readerName,
int perSegmentDocumentNumber,
int perIndexDocumentNumber,
Document document,
string id,
NuGetVersion version)
{
HashSet<string> registrationOwners;
if (id != null && _owners.TryGetValue(id, out registrationOwners))
{
foreach (string registrationOwner in registrationOwners)
{
_knownOwners.Add(registrationOwner);
DynamicDocIdSet ownerDocIdSet;
if (_ownerTuples[readerName].TryGetValue(registrationOwner, out ownerDocIdSet))
{
ownerDocIdSet.DocIds.Add(perSegmentDocumentNumber);
}
else
{
ownerDocIdSet = new DynamicDocIdSet();
ownerDocIdSet.DocIds.Add(perSegmentDocumentNumber);
_ownerTuples[readerName].Add(registrationOwner, ownerDocIdSet);
}
}
}
}
示例6: TryParse
/// <summary>
/// Parses a version string using loose semantic versioning rules that allows 2-4 version components followed
/// by an optional special version.
/// </summary>
public static bool TryParse(string value, out NuGetVersion version)
{
version = null;
if (value != null)
{
Version systemVersion = null;
// trim the value before passing it in since we not strict here
var sections = ParseSections(value.Trim());
// null indicates the string did not meet the rules
if (sections != null
&& !string.IsNullOrEmpty(sections.Item1))
{
var versionPart = sections.Item1;
if (versionPart.IndexOf('.') < 0)
{
// System.Version requires at least a 2 part version to parse.
versionPart += ".0";
}
if (Version.TryParse(versionPart, out systemVersion))
{
// labels
if (sections.Item2 != null
&& !sections.Item2.All(s => IsValidPart(s, false)))
{
return false;
}
// build metadata
if (sections.Item3 != null
&& !IsValid(sections.Item3, true))
{
return false;
}
var ver = NormalizeVersionValue(systemVersion);
var originalVersion = value;
if (originalVersion.IndexOf(' ') > -1)
{
originalVersion = value.Replace(" ", "");
}
version = new NuGetVersion(version: ver,
releaseLabels: sections.Item2,
metadata: sections.Item3 ?? string.Empty,
originalVersion: originalVersion);
return true;
}
}
}
return false;
}
示例7: GetDependencyInfoAsync
public override Task<FindPackageByIdDependencyInfo> GetDependencyInfoAsync(string id, NuGetVersion version, CancellationToken token)
{
var info = GetPackageInfo(id, version);
FindPackageByIdDependencyInfo dependencyInfo = null;
if (info != null)
{
var nuspecPath = Path.Combine(info.Path, $"{id}.nuspec");
using (var stream = File.OpenRead(nuspecPath))
{
NuspecReader nuspecReader;
try
{
nuspecReader = new NuspecReader(stream);
}
catch (XmlException ex)
{
var message = string.Format(CultureInfo.CurrentCulture, Strings.Protocol_PackageMetadataError, id + "." + version, _source);
throw new NuGetProtocolException(message, ex);
}
catch (PackagingException ex)
{
var message = string.Format(CultureInfo.CurrentCulture, Strings.Protocol_PackageMetadataError, id + "." + version, _source);
throw new NuGetProtocolException(message, ex);
}
dependencyInfo = GetDependencyInfo(nuspecReader);
}
}
return Task.FromResult(dependencyInfo);
}
示例8: LocalPackageInfo
public LocalPackageInfo(string packageId, NuGetVersion version, string path)
{
Id = packageId;
Version = version;
ExpandedPath = path;
ManifestPath = Path.Combine(path, string.Format("{0}.nuspec", Id));
ZipPath = Path.Combine(path, string.Format("{0}.{1}.nupkg", Id, Version));
}
示例9: CreatePackageIdentity
static PackageIdentity CreatePackageIdentity (string packageId, string packageVersion)
{
NuGetVersion nuGetVersion = null;
if (packageVersion != null) {
nuGetVersion = new NuGetVersion (packageVersion);
}
return new PackageIdentity (packageId, nuGetVersion);
}
示例10: GetLockFilePath
public string GetLockFilePath(string packageId, NuGetVersion version, NuGetFramework framework)
{
return Path.Combine(
GetBaseToolPath(packageId),
version.ToNormalizedString(),
framework.GetShortFolderName(),
"project.lock.json");
}
示例11: GetUri
/// <summary>
/// Constructs the URI of a registration blob with a specific version
/// </summary>
public virtual Uri GetUri(string id, NuGetVersion version)
{
if (String.IsNullOrEmpty(id) || version == null)
{
throw new InvalidOperationException();
}
return GetUri(new PackageIdentity(id, version));
}
示例12: UserAction
public UserAction(NuGetProjectActionType action, string packageId, NuGetVersion packageVersion)
{
Action = action;
PackageId = packageId;
if(packageVersion != null)
{
PackageIdentity = new PackageIdentity(packageId, packageVersion);
}
}
示例13: WriteMinClientVersion
/// <summary>
/// Write a minimum client version to packages.config
/// </summary>
/// <param name="version">Minumum version of the client required to parse and use this file.</param>
public void WriteMinClientVersion(NuGetVersion version)
{
if (_minClientVersion != null)
{
throw new PackagingException(String.Format(CultureInfo.InvariantCulture, "MinClientVersion already exists"));
}
_minClientVersion = version;
}
示例14: CreatePackageReference
void CreatePackageReference (
string packageId = "Id",
string packageVersion = "1.2.3",
bool requireReinstallation = false)
{
var version = new NuGetVersion (packageVersion);
var identity = new PackageIdentity (packageId, version);
packageReference = new PackageReference (identity, null, true, false, requireReinstallation);
}
示例15: Clone
public static PackageReference Clone( this PackageReference source, NuGetVersion version = null )
{
return new PackageReference( new PackageIdentity( source.PackageIdentity.Id, version ?? source.PackageIdentity.Version ),
source.TargetFramework,
source.IsUserInstalled,
source.IsDevelopmentDependency,
source.RequireReinstallation,
source.AllowedVersions );
}