-
Notifications
You must be signed in to change notification settings - Fork 1k
/
MockPackageResolver.cs
30 lines (26 loc) · 1.08 KB
/
MockPackageResolver.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
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using NuGet.ProjectModel;
using NuGet.Versioning;
namespace Microsoft.NET.Build.Tasks.UnitTests
{
public class MockPackageResolver : IPackageResolver
{
private readonly string _root;
public MockPackageResolver(string root = "/root")
{
_root = root;
}
public string GetPackageDirectory(string packageId, NuGetVersion version)
{
string packageRoot = null;
return GetPackageDirectory(packageId, version, out packageRoot);
}
public string GetPackageDirectory(string packageId, NuGetVersion version, out string packageRoot)
{
packageRoot = _root;
return Path.Combine(_root, packageId, version.ToNormalizedString(), "path");
}
public string ResolvePackageAssetPath(LockFileTargetLibrary package, string relativePath) => Path.Combine(GetPackageDirectory(package.Name, package.Version), relativePath);
}
}