dotnet-installer/src/Microsoft.DotNet.ProjectModel/PackageDescription.cs

54 lines
1.9 KiB
C#
Raw Normal View History

// Copyright (c) .NET Foundation and contributors. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
using System.Collections.Generic;
using System.Linq;
using Microsoft.DotNet.ProjectModel.Resolution;
using NuGet.LibraryModel;
using NuGet.ProjectModel;
namespace Microsoft.DotNet.ProjectModel
{
2016-03-23 15:26:36 -07:00
public class PackageDescription : TargetLibraryWithAssets
{
public PackageDescription(
string path,
string hashPath,
LockFileLibrary package,
LockFileTargetLibrary lockFileLibrary,
IEnumerable<ProjectLibraryDependency> dependencies,
bool compatible,
bool resolved)
: base(
new LibraryIdentity(package.Name, package.Version, LibraryType.Package),
"sha512-" + package.Sha512,
path,
2016-03-23 15:26:36 -07:00
lockFileLibrary,
dependencies,
resolved: resolved,
2016-03-23 15:26:36 -07:00
compatible: compatible,
framework: null)
{
HashPath = hashPath;
2016-03-23 15:26:36 -07:00
PackageLibrary = package;
}
public string HashPath { get; }
public LockFileLibrary PackageLibrary { get; }
2016-03-23 15:26:36 -07:00
public override IEnumerable<LockFileItem> RuntimeAssemblies => FilterPlaceholders(base.RuntimeAssemblies);
2016-03-23 15:26:36 -07:00
public override IEnumerable<LockFileItem> CompileTimeAssemblies => FilterPlaceholders(base.CompileTimeAssemblies);
public bool HasCompileTimePlaceholder =>
base.CompileTimeAssemblies.Any() &&
base.CompileTimeAssemblies.All(a => PackageDependencyProvider.IsPlaceholderFile(a.Path));
2016-03-23 15:26:36 -07:00
private static IEnumerable<LockFileItem> FilterPlaceholders(IEnumerable<LockFileItem> items)
{
return items.Where(a => !PackageDependencyProvider.IsPlaceholderFile(a.Path));
2016-03-23 15:26:36 -07:00
}
}
}