本文整理汇总了C#中IPackagePathResolver.GetInstallPath方法的典型用法代码示例。如果您正苦于以下问题:C# IPackagePathResolver.GetInstallPath方法的具体用法?C# IPackagePathResolver.GetInstallPath怎么用?C# IPackagePathResolver.GetInstallPath使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IPackagePathResolver
的用法示例。
在下文中一共展示了IPackagePathResolver.GetInstallPath方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateLockFileLibrary
public static LockFileLibrary CreateLockFileLibrary(LockFileLibrary previousLibrary, IPackagePathResolver resolver, IPackage package, string correctedPackageName = null)
{
var lockFileLib = new LockFileLibrary();
// package.Id is read from nuspec and it might be in wrong casing.
// correctedPackageName should be the package name used by dependency graph and
// it has the correct casing that runtime needs during dependency resolution.
lockFileLib.Name = correctedPackageName ?? package.Id;
lockFileLib.Version = package.Version;
lockFileLib.Sha512 = File.ReadAllText(resolver.GetHashPath(package.Id, package.Version));
// If the shas are equal then do nothing
if (previousLibrary?.Sha512 == lockFileLib.Sha512)
{
lockFileLib.Files = previousLibrary.Files;
lockFileLib.IsServiceable = previousLibrary.IsServiceable;
}
else
{
lockFileLib.Files = package.GetFiles().Select(p => p.Path).ToList();
var installPath = resolver.GetInstallPath(package.Id, package.Version);
foreach (var filePath in lockFileLib.Files)
{
if (!string.Equals(Path.GetExtension(filePath), ".dll", StringComparison.OrdinalIgnoreCase))
{
continue;
}
var assemblyPath = Path.Combine(installPath, filePath);
try
{
if (IsAssemblyServiceable(assemblyPath))
{
lockFileLib.IsServiceable = true;
break;
}
}
catch
{
// Just move on to the next file
}
}
}
return lockFileLib;
}
示例2: ResolvePackagePath
private static string ResolvePackagePath(IPackagePathResolver defaultResolver,
IEnumerable<IPackagePathResolver> cacheResolvers,
IPackage package)
{
var defaultHashPath = defaultResolver.GetHashPath(package.Id, package.Version);
foreach (var resolver in cacheResolvers)
{
var cacheHashFile = resolver.GetHashPath(package.Id, package.Version);
// REVIEW: More efficient compare?
if (File.Exists(defaultHashPath) &&
File.Exists(cacheHashFile) &&
File.ReadAllText(defaultHashPath) == File.ReadAllText(cacheHashFile))
{
return resolver.GetInstallPath(package.Id, package.Version);
}
}
return defaultResolver.GetInstallPath(package.Id, package.Version);
}
示例3: ResolvePackagePath
private string ResolvePackagePath(IPackagePathResolver defaultResolver,
IEnumerable<IPackagePathResolver> cacheResolvers,
PackageInfo packageInfo)
{
string expectedHash = packageInfo.LockFileLibrary.Sha;
foreach (var resolver in cacheResolvers)
{
var cacheHashFile = resolver.GetHashPath(packageInfo.Id, packageInfo.Version);
// REVIEW: More efficient compare?
if (File.Exists(cacheHashFile) &&
File.ReadAllText(cacheHashFile) == expectedHash)
{
return resolver.GetInstallPath(packageInfo.Id, packageInfo.Version);
}
}
return defaultResolver.GetInstallPath(packageInfo.Id, packageInfo.Version);
}
示例4: CreateLockFileLibraryForProject
public static LockFileLibrary CreateLockFileLibraryForProject(
Runtime.Project project,
IPackage package,
SHA512 sha512,
IEnumerable<FrameworkName> frameworks,
IPackagePathResolver resolver,
string correctedPackageName = null)
{
var lockFileLib = new LockFileLibrary();
// package.Id is read from nuspec and it might be in wrong casing.
// correctedPackageName should be the package name used by dependency graph and
// it has the correct casing that runtime needs during dependency resolution.
lockFileLib.Name = correctedPackageName ?? package.Id;
lockFileLib.Version = package.Version;
using (var nupkgStream = package.GetStream())
{
lockFileLib.Sha = Convert.ToBase64String(sha512.ComputeHash(nupkgStream));
}
lockFileLib.Files = package.GetFiles().Select(p => p.Path).ToList();
foreach (var framework in frameworks)
{
var group = new LockFileFrameworkGroup();
group.TargetFramework = framework;
IEnumerable<PackageDependencySet> dependencySet;
if (VersionUtility.TryGetCompatibleItems(framework, package.DependencySets, out dependencySet))
{
var set = dependencySet.FirstOrDefault()?.Dependencies?.ToList();
if (set != null)
{
group.Dependencies = set;
}
}
// TODO: Remove this when we do #596
// ASP.NET Core isn't compatible with generic PCL profiles
if (!string.Equals(framework.Identifier, VersionUtility.AspNetCoreFrameworkIdentifier, StringComparison.OrdinalIgnoreCase) &&
!string.Equals(framework.Identifier, VersionUtility.DnxCoreFrameworkIdentifier, StringComparison.OrdinalIgnoreCase))
{
IEnumerable<FrameworkAssemblyReference> frameworkAssemblies;
if (VersionUtility.TryGetCompatibleItems(framework, package.FrameworkAssemblies, out frameworkAssemblies))
{
foreach (var assemblyReference in frameworkAssemblies)
{
if (!assemblyReference.SupportedFrameworks.Any() &&
!VersionUtility.IsDesktop(framework))
{
// REVIEW: This isn't 100% correct since none *can* mean
// any in theory, but in practice it means .NET full reference assembly
// If there's no supported target frameworks and we're not targeting
// the desktop framework then skip it.
// To do this properly we'll need all reference assemblies supported
// by each supported target framework which isn't always available.
continue;
}
group.FrameworkAssemblies.Add(assemblyReference);
}
}
}
group.RuntimeAssemblies = GetPackageAssemblies(package, framework);
string contractPath = Path.Combine("lib", "contract", package.Id + ".dll");
var hasContract = lockFileLib.Files.Any(path => path == contractPath);
var hasLib = group.RuntimeAssemblies.Any();
if (hasContract && hasLib && !VersionUtility.IsDesktop(framework))
{
group.CompileTimeAssemblies.Add(contractPath);
}
else if (hasLib)
{
group.CompileTimeAssemblies.AddRange(group.RuntimeAssemblies);
}
lockFileLib.FrameworkGroups.Add(group);
}
var installPath = resolver.GetInstallPath(package.Id, package.Version);
foreach (var assembly in lockFileLib.FrameworkGroups.SelectMany(f => f.RuntimeAssemblies))
{
var assemblyPath = Path.Combine(installPath, assembly);
if (IsAssemblyServiceable(assemblyPath))
{
lockFileLib.IsServiceable = true;
break;
}
}
return lockFileLib;
}