Skip to content

Commit 170dfeb

Browse files
committed
Move interface to its own file
1 parent 284c974 commit 170dfeb

2 files changed

Lines changed: 35 additions & 26 deletions

File tree

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
// Copyright (c) .NET Foundation. All rights reserved.
2+
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
3+
4+
#nullable enable
5+
6+
using System;
7+
using System.IO;
8+
using System.Linq;
9+
using System.Reflection;
10+
using Microsoft.Build.Construction;
11+
using Microsoft.Build.Evaluation;
12+
13+
namespace NuGet.CommandLine.XPlat;
14+
15+
public interface IVirtualProjectBuilder
16+
{
17+
bool IsValidEntryPointPath(string entryPointFilePath);
18+
19+
ProjectRootElement CreateProjectRootElement(string entryPointFilePath, ProjectCollection projectCollection);
20+
21+
internal static IVirtualProjectBuilder? TryLoad()
22+
{
23+
var assemblyPath = Path.Join(AppContext.BaseDirectory, "dotnet.dll");
24+
25+
if (!File.Exists(assemblyPath))
26+
{
27+
return null;
28+
}
29+
30+
var type = Assembly.LoadFile(assemblyPath)
31+
.GetExportedTypes()
32+
.FirstOrDefault(static t => t.IsAssignableTo(typeof(IVirtualProjectBuilder)));
33+
return type != null ? (IVirtualProjectBuilder?)Activator.CreateInstance(type) : null;
34+
}
35+
}

src/NuGet.Core/NuGet.CommandLine.XPlat/NuGetCommands.cs

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,7 @@
55

66
using System;
77
using System.CommandLine;
8-
using System.IO;
98
using System.Linq;
10-
using System.Reflection;
11-
using Microsoft.Build.Construction;
12-
using Microsoft.Build.Evaluation;
139
using NuGet.CommandLine.XPlat.Commands.Package.PackageDownload;
1410
using NuGet.CommandLine.XPlat.Commands.Package.Update;
1511

@@ -51,25 +47,3 @@ public static void Add(RootCommand rootCommand)
5147
Add(rootCommand, interactiveOption);
5248
}
5349
}
54-
55-
public interface IVirtualProjectBuilder
56-
{
57-
bool IsValidEntryPointPath(string entryPointFilePath);
58-
59-
ProjectRootElement CreateProjectRootElement(string entryPointFilePath, ProjectCollection projectCollection);
60-
61-
internal static IVirtualProjectBuilder? TryLoad()
62-
{
63-
var assemblyPath = Path.Join(AppContext.BaseDirectory, "dotnet.dll");
64-
65-
if (!File.Exists(assemblyPath))
66-
{
67-
return null;
68-
}
69-
70-
var type = Assembly.LoadFile(assemblyPath)
71-
.GetExportedTypes()
72-
.FirstOrDefault(static t => t.IsAssignableTo(typeof(IVirtualProjectBuilder)));
73-
return type != null ? (IVirtualProjectBuilder?)Activator.CreateInstance(type) : null;
74-
}
75-
}

0 commit comments

Comments
 (0)