This repository has been archived by the owner on Jan 23, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 219
/
CompilationLibrary.cs
64 lines (57 loc) · 2.14 KB
/
CompilationLibrary.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
// 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;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Extensions.DependencyModel.Resolution;
namespace Microsoft.Extensions.DependencyModel
{
public class CompilationLibrary : Library
{
public CompilationLibrary(string type,
string name,
string version,
string hash,
IEnumerable<string> assemblies,
IEnumerable<Dependency> dependencies,
bool serviceable)
: this(type, name, version, hash, assemblies, dependencies, serviceable, path: null)
{
}
public CompilationLibrary(string type,
string name,
string version,
string hash,
IEnumerable<string> assemblies,
IEnumerable<Dependency> dependencies,
bool serviceable,
string path)
: base(type, name, version, hash, dependencies, serviceable, path)
{
if (assemblies == null)
{
throw new ArgumentNullException(nameof(assemblies));
}
Assemblies = assemblies.ToArray();
}
public IReadOnlyList<string> Assemblies { get; }
#if !NETSTANDARD1_3
internal static ICompilationAssemblyResolver DefaultResolver { get; } = new CompositeCompilationAssemblyResolver(new ICompilationAssemblyResolver[]
{
new PackageCacheCompilationAssemblyResolver(),
new AppBaseCompilationAssemblyResolver(),
new ReferenceAssemblyPathResolver(),
new PackageCompilationAssemblyResolver()
});
public IEnumerable<string> ResolveReferencePaths()
{
var assemblies = new List<string>();
if (!DefaultResolver.TryResolveAssemblyPaths(this, assemblies))
{
throw new InvalidOperationException($"Can not find compilation library location for package '{Name}'");
}
return assemblies;
}
#endif
}
}