-
Notifications
You must be signed in to change notification settings - Fork 756
Add support for file-based apps to the XPlat CLI #7169
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 7 commits
Commits
Show all changes
30 commits
Select commit
Hold shift + click to select a range
3d40dcc
Support file-based apps in place of projects in the xplat CLI
jjonescz 90bdcb5
Add package reference
jjonescz 3435c86
Pass project collection to the API
jjonescz 9cc867e
Let SDK provide the API to avoid a circular dependency
jjonescz 284c974
Load dotnet.dll
jjonescz 170dfeb
Move interface to its own file
jjonescz d730f85
Add a comment
jjonescz 68fc9e7
Add a parameter for project content file
jjonescz 09bec45
Merge branch 'dev' into 14390-fbp-2
jjonescz dea79fe
Avoid hard-coding .cs extension
jjonescz 3f5eb66
Use correct MSBuild
jjonescz 5115070
Use API again instead of a command-line option
jjonescz d97bad3
Merge branch 'dev' into 14390-fbp-2
jjonescz 0e72883
Fixup after merge
jjonescz 0f8f395
Improve code
jjonescz bff2206
Avoid using IVirtualProjectBuilder singletons
jjonescz 4dba4eb
Merge branch 'dev' into 14390-fbp-2
jjonescz ca21710
Improve reflection
jjonescz db37ef1
Remove unnecessary check
jjonescz 92020d5
Use SDK-provided project path
jjonescz 7eecf67
Add public Program.Run API
jjonescz 54cc213
Add SaveProject API
jjonescz e4aef8c
Handle Why command API
jjonescz dde5c33
Add unit tests
jjonescz b4fa7b1
Update help texts
jjonescz 44944b2
Fixup a test
jjonescz 2fc9af8
Improve code
jjonescz ea57406
Fixup restore option passed to msbuild
jjonescz 335a3a8
Link a tracking issue
jjonescz 97908b6
Simplify unit test utility
jjonescz File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
40 changes: 40 additions & 0 deletions
40
src/NuGet.Core/NuGet.CommandLine.XPlat/IVirtualProjectBuilder.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| // Copyright (c) .NET Foundation. All rights reserved. | ||
| // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. | ||
|
|
||
| #nullable enable | ||
|
|
||
| using System; | ||
| using System.IO; | ||
| using System.Linq; | ||
| using System.Reflection; | ||
| using Microsoft.Build.Construction; | ||
| using Microsoft.Build.Evaluation; | ||
|
|
||
| namespace NuGet.CommandLine.XPlat; | ||
|
|
||
| /// <summary> | ||
| /// We cannot have a dependency on a package from SDK due to source build, | ||
| /// hence we invert the relationship and define the interface here, | ||
| /// SDK implements it and we load the implementation dynamically. | ||
| /// </summary> | ||
| public interface IVirtualProjectBuilder | ||
| { | ||
| bool IsValidEntryPointPath(string entryPointFilePath); | ||
|
|
||
| ProjectRootElement CreateProjectRootElement(string entryPointFilePath, ProjectCollection projectCollection); | ||
|
|
||
| internal static IVirtualProjectBuilder? TryLoad() | ||
|
jjonescz marked this conversation as resolved.
Outdated
|
||
| { | ||
| var assemblyPath = Path.Join(AppContext.BaseDirectory, "dotnet.dll"); | ||
|
jjonescz marked this conversation as resolved.
Outdated
|
||
|
|
||
| if (!File.Exists(assemblyPath)) | ||
| { | ||
| return null; | ||
| } | ||
|
|
||
| var type = Assembly.LoadFile(assemblyPath) | ||
| .GetExportedTypes() | ||
| .FirstOrDefault(static t => t.IsAssignableTo(typeof(IVirtualProjectBuilder))); | ||
| return type != null ? (IVirtualProjectBuilder?)Activator.CreateInstance(type) : null; | ||
| } | ||
| } | ||
3 changes: 3 additions & 0 deletions
3
src/NuGet.Core/NuGet.CommandLine.XPlat/PublicAPI.Unshipped.txt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1,4 @@ | ||
| #nullable enable | ||
| NuGet.CommandLine.XPlat.IVirtualProjectBuilder | ||
| NuGet.CommandLine.XPlat.IVirtualProjectBuilder.CreateProjectRootElement(string! entryPointFilePath, Microsoft.Build.Evaluation.ProjectCollection! projectCollection) -> Microsoft.Build.Construction.ProjectRootElement! | ||
| NuGet.CommandLine.XPlat.IVirtualProjectBuilder.IsValidEntryPointPath(string! entryPointFilePath) -> bool |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.