File tree Expand file tree Collapse file tree
src/NuGet.Core/NuGet.CommandLine.XPlat Expand file tree Collapse file tree Original file line number Diff line number Diff line change 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+ }
Original file line number Diff line number Diff line change 55
66using System ;
77using System . CommandLine ;
8- using System . IO ;
98using System . Linq ;
10- using System . Reflection ;
11- using Microsoft . Build . Construction ;
12- using Microsoft . Build . Evaluation ;
139using NuGet . CommandLine . XPlat . Commands . Package . PackageDownload ;
1410using 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- }
You can’t perform that action at this time.
0 commit comments