本文整理汇总了C#中LibraryRange类的典型用法代码示例。如果您正苦于以下问题:C# LibraryRange类的具体用法?C# LibraryRange怎么用?C# LibraryRange使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
LibraryRange类属于命名空间,在下文中一共展示了LibraryRange类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RuntimeStyleLibraryRangeToString
// DNU REFACTORING TODO: temp hack to make generated lockfile work with runtime lockfile validation
private static string RuntimeStyleLibraryRangeToString(LibraryRange libraryRange)
{
var sb = new StringBuilder();
sb.Append(libraryRange.Name);
sb.Append(" ");
if (libraryRange.VersionRange == null)
{
return sb.ToString();
}
var minVersion = libraryRange.VersionRange.MinVersion;
var maxVersion = libraryRange.VersionRange.MaxVersion;
sb.Append(">= ");
if (libraryRange.VersionRange.IsFloating)
{
sb.Append(libraryRange.VersionRange.Float.ToString());
}
else
{
sb.Append(minVersion.ToString());
}
if (maxVersion != null)
{
sb.Append(libraryRange.VersionRange.IsMaxInclusive ? "<= " : "< ");
sb.Append(maxVersion.Version.ToString());
}
return sb.ToString();
}
示例2: GetDescription
public LibraryDescription GetDescription(LibraryRange libraryRange, FrameworkName targetFramework)
{
if (!libraryRange.IsGacOrFrameworkReference)
{
return null;
}
if (!RuntimeEnvironmentHelper.IsWindows)
{
return null;
}
if (!VersionUtility.IsDesktop(targetFramework))
{
return null;
}
var name = libraryRange.Name;
var version = libraryRange.VersionRange?.MinVersion;
string path;
if (!TryResolvePartialName(libraryRange.GetReferenceAssemblyName(), version, targetFramework, out path))
{
return null;
}
return new LibraryDescription(
libraryRange,
new LibraryIdentity(name, version, isGacOrFrameworkReference: true),
path,
LibraryTypes.GlobalAssemblyCache,
Enumerable.Empty<LibraryDependency>(),
new[] { libraryRange.GetReferenceAssemblyName() },
framework: targetFramework);
}
示例3: GetLibrary
public Library GetLibrary(LibraryRange libraryRange, NuGetFramework targetFramework)
{
var package = FindCandidate(libraryRange.Name, libraryRange.VersionRange);
if (package != null)
{
NuspecReader nuspecReader = null;
using (var stream = File.OpenRead(package.ManifestPath))
{
nuspecReader = new NuspecReader(stream);
}
var description = new Library
{
LibraryRange = libraryRange,
Identity = new LibraryIdentity
{
Name = package.Id,
Version = package.Version,
Type = LibraryTypes.Package
},
Path = package.ManifestPath,
Dependencies = GetDependencies(nuspecReader, targetFramework)
};
description.Items["package"] = package;
description.Items["metadata"] = nuspecReader;
return description;
}
return null;
}
示例4: FindLibrary
public async Task<WalkProviderMatch> FindLibrary(LibraryRange libraryRange, FrameworkName targetFramework, bool includeUnlisted)
{
var results = await _source.FindPackagesByIdAsync(libraryRange.Name);
PackageInfo bestResult = null;
if(!includeUnlisted)
{
results = results.Where(p => p.Listed);
}
foreach (var result in results)
{
if (VersionUtility.ShouldUseConsidering(
current: bestResult?.Version,
considering: result.Version,
ideal: libraryRange.VersionRange))
{
bestResult = result;
}
}
if (bestResult == null)
{
return null;
}
return new WalkProviderMatch
{
Library = new LibraryIdentity(bestResult.Id, bestResult.Version, isGacOrFrameworkReference: false),
Path = bestResult.ContentUri,
Provider = this,
};
}
示例5: GetDescription
public LibraryDescription GetDescription(LibraryRange libraryRange, FrameworkName targetFramework)
{
if (!DependencyTargets.SupportsPackage(libraryRange.Target))
{
return null;
}
var versionRange = libraryRange.VersionRange;
var package = FindCandidate(libraryRange.Name, versionRange);
if (package != null)
{
var dependencies = GetDependencies(package, targetFramework);
return new LibraryDescription(
libraryRange,
new LibraryIdentity(package.Id, package.Version, isGacOrFrameworkReference: false),
path: null,
type: LibraryTypes.Package,
dependencies: dependencies,
assemblies: null,
framework: null);
}
return null;
}
示例6: GetDescription
public LibraryDescription GetDescription(LibraryRange libraryRange, NuGetFramework targetFramework)
{
if (!LibraryType.ReferenceAssembly.CanSatisfyConstraint(libraryRange.Target))
{
return null;
}
var name = libraryRange.Name;
var version = libraryRange.VersionRange?.MinVersion;
string path;
Version assemblyVersion;
if (!FrameworkResolver.TryGetAssembly(name, targetFramework, out path, out assemblyVersion))
{
return null;
}
return new LibraryDescription(
new LibraryIdentity(libraryRange.Name, new NuGetVersion(assemblyVersion), LibraryType.ReferenceAssembly),
string.Empty, // Framework assemblies don't have hashes
path,
Enumerable.Empty<LibraryRange>(),
targetFramework,
resolved: true,
compatible: true);
}
示例7: FindLibrary
public async Task<WalkProviderMatch> FindLibrary(LibraryRange libraryRange, FrameworkName targetFramework)
{
var results = await _source.FindPackagesByIdAsync(libraryRange.Name);
PackageInfo bestResult = null;
foreach (var result in results)
{
if (VersionUtility.ShouldUseConsidering(
current: bestResult?.Version,
considering: result.Version,
ideal: libraryRange.VersionRange))
{
bestResult = result;
}
}
if (bestResult == null)
{
return null;
}
return new WalkProviderMatch
{
Library = new Library
{
Name = bestResult.Id,
Version = bestResult.Version
},
Path = bestResult.ContentUri,
Provider = this,
};
}
示例8: GetDescription
public Library GetDescription(LibraryRange libraryRange, NuGetFramework targetFramework)
{
Debug.Assert(SupportsType(libraryRange.TypeConstraint));
var name = libraryRange.Name;
var version = libraryRange.VersionRange?.MinVersion;
string path;
NuGetVersion assemblyVersion;
if (!FrameworkResolver.TryGetAssembly(name, targetFramework, out path, out assemblyVersion))
{
Log.LogWarning($"Unable to resolve requested assembly {libraryRange.Name}");
return null;
}
if (version == null || version == assemblyVersion)
{
return new Library
{
LibraryRange = libraryRange,
Identity = new LibraryIdentity
{
Name = name,
Version = assemblyVersion,
Type = LibraryTypes.Reference
},
Dependencies = Enumerable.Empty<LibraryDependency>(),
[KnownLibraryProperties.AssemblyPath] = path
};
}
return null;
}
示例9: GetDescription
public LibraryDescription GetDescription(LibraryRange libraryRange, FrameworkName targetFramework)
{
if (!libraryRange.IsGacOrFrameworkReference)
{
return null;
}
var name = libraryRange.GetReferenceAssemblyName();
var version = libraryRange.VersionRange?.MinVersion;
string path;
Version assemblyVersion;
if (!FrameworkResolver.TryGetAssembly(name, targetFramework, out path, out assemblyVersion))
{
return null;
}
if (version == null || version.Version == assemblyVersion)
{
return new LibraryDescription(
libraryRange,
new LibraryIdentity(libraryRange.Name, new SemanticVersion(assemblyVersion), isGacOrFrameworkReference: true),
path,
LibraryTypes.ReferenceAssembly,
Enumerable.Empty<LibraryDependency>(),
new[] { name },
framework: targetFramework);
}
return null;
}
示例10: GetDescription
public LibraryDescription GetDescription(LibraryRange libraryRange, FrameworkName targetFramework)
{
if (libraryRange.IsGacOrFrameworkReference)
{
return null;
}
if (!DependencyTargets.SupportsProject(libraryRange.Target))
{
return null;
}
string name = libraryRange.Name;
Runtime.Project project;
// Can't find a project file with the name so bail
if (!_projectResolver.TryResolveProject(name, out project))
{
return null;
}
// This never returns null
var targetFrameworkInfo = project.GetCompatibleTargetFramework(targetFramework);
var dependencies = project.Dependencies.Concat(targetFrameworkInfo.Dependencies).ToList();
return new ProjectDescription(
libraryRange,
project,
dependencies,
Enumerable.Empty<string>(),
targetFrameworkInfo,
resolved: true);
}
示例11: GetLibrary
public Library GetLibrary(LibraryRange libraryRange, NuGetFramework targetFramework)
{
var key = Tuple.Create(targetFramework, libraryRange.Name);
LockFileTargetLibrary library = null;
// Determine if we have a library for this target
if (_targetLibraries.TryGetValue(key, out library) &&
libraryRange.VersionRange.IsBetter(current: null, considering: library.Version))
{
var dependencies = GetDependencies(library, targetFramework);
var description = new Library {
LibraryRange = libraryRange,
Identity = new LibraryIdentity
{
Name = library.Name,
Version = library.Version,
Type = LibraryTypes.Package
},
Resolved = true,
Dependencies = dependencies,
[KnownLibraryProperties.LockFileLibrary] = _libraries[Tuple.Create(library.Name, library.Version)],
[KnownLibraryProperties.LockFileTargetLibrary] = library
};
return description;
}
return null;
}
示例12: GetLibrary
public Library GetLibrary(LibraryRange libraryRange, NuGetFramework targetFramework)
{
ExternalProjectReference externalProject;
if (!ExternalProjects.TryGetValue(libraryRange.Name, out externalProject))
{
// No project!
return null;
}
// Fill dependencies from external project references
var dependencies = externalProject.ExternalProjectReferences.Select(s => new LibraryDependency()
{
LibraryRange = new LibraryRange()
{
Name = s,
VersionRange = null,
TypeConstraint = LibraryTypes.ExternalProject
},
Type = LibraryDependencyType.Default
}).ToList();
// Add dependencies from the nuget.json file
if (!string.IsNullOrEmpty(externalProject.PackageSpecPath)
&& File.Exists(externalProject.PackageSpecPath))
{
PackageSpec packageSpec;
using (var stream = new FileStream(externalProject.PackageSpecPath, FileMode.Open, FileAccess.Read, FileShare.Read))
{
packageSpec = JsonPackageSpecReader.GetPackageSpec(stream, externalProject.Name, externalProject.PackageSpecPath);
}
// Add framework-agnostic dependencies
dependencies.AddRange(packageSpec.Dependencies);
// Add framework-specific dependencies
var frameworkInfo = packageSpec.GetTargetFramework(targetFramework);
if (frameworkInfo != null)
{
dependencies.AddRange(frameworkInfo.Dependencies);
}
}
// Construct the library and return it
return new Library()
{
Identity = new LibraryIdentity()
{
Name = externalProject.Name,
Version = new NuGetVersion("1.0.0"),
Type = LibraryTypes.ExternalProject
},
LibraryRange = libraryRange,
Dependencies = dependencies,
Path = externalProject.PackageSpecPath,
Resolved = true
};
}
示例13: GetDependencyItem
private static DependencyItem GetDependencyItem(LibraryRange dependency,
IDictionary<string, LibraryExport> exportsLookup)
{
return new DependencyItem
{
Name = dependency.Name,
Version = exportsLookup[dependency.Name].Library.Identity.Version?.ToNormalizedString()
};
}
示例14: RunPackageInstall
public static int RunPackageInstall(LibraryRange dependency, string projectPath, IEnumerable<string> args)
{
var result = RunDnx(new List<string> { "install", dependency.Name, dependency.VersionRange.OriginalString, projectPath }.Concat(args))
.ForwardStdErr()
.ForwardStdOut()
.Execute();
return result.ExitCode;
}
示例15: RenderDependency
private string RenderDependency(LibraryRange arg)
{
var name = arg.Name;
if (arg.Target == LibraryType.ReferenceAssembly)
{
name = $"fx/{name}";
}
return $"{name} {VersionUtility.RenderVersion(arg.VersionRange)}";
}