Merge pull request #9788 from dasMulli/feature/complete-suggest-configurations
Complete configurations based on project file if present.
This commit is contained in:
commit
8ca823bfd6
4 changed files with 20 additions and 3 deletions
|
@ -52,7 +52,7 @@ namespace Microsoft.DotNet.Cli
|
|||
description,
|
||||
Accept.ExactlyOneArgument()
|
||||
.With(name: CommonLocalizableStrings.ConfigurationArgumentName)
|
||||
.WithSuggestionsFrom("Debug", "Release")
|
||||
.WithSuggestionsFrom(_ => Suggest.ConfigurationsFromProjectFileOrDefaults())
|
||||
.ForwardAsSingle(o => $"-property:Configuration={o.Arguments.Single()}"));
|
||||
|
||||
public static Option VersionSuffixOption() =>
|
||||
|
|
|
@ -25,6 +25,7 @@ namespace Microsoft.DotNet.Tools
|
|||
private ProjectCollection _projects;
|
||||
private List<NuGetFramework> _cachedTfms = null;
|
||||
private IEnumerable<string> cachedRuntimeIdentifiers;
|
||||
private IEnumerable<string> cachedConfigurations;
|
||||
|
||||
private MsbuildProject(ProjectCollection projects, ProjectRootElement project)
|
||||
{
|
||||
|
@ -168,6 +169,12 @@ namespace Microsoft.DotNet.Tools
|
|||
return _cachedTfms;
|
||||
}
|
||||
|
||||
public IEnumerable<string> GetConfigurations()
|
||||
{
|
||||
return cachedConfigurations ??
|
||||
(cachedConfigurations = GetEvaluatedProject().GetConfigurations());
|
||||
}
|
||||
|
||||
public bool CanWorkOnFramework(NuGetFramework framework)
|
||||
{
|
||||
foreach (var tfm in GetTargetFrameworks())
|
||||
|
|
|
@ -32,6 +32,11 @@ namespace Microsoft.DotNet.Tools.ProjectExtensions
|
|||
.Select((frameworkString) => NuGetFramework.Parse(frameworkString));
|
||||
}
|
||||
|
||||
public static IEnumerable<string> GetConfigurations(this Project project)
|
||||
{
|
||||
return project.GetPropertyCommaSeparatedValues("Configurations");
|
||||
}
|
||||
|
||||
public static IEnumerable<string> GetPropertyCommaSeparatedValues(this Project project, string propertyName)
|
||||
{
|
||||
return project.GetPropertyValue(propertyName)
|
||||
|
|
|
@ -40,6 +40,11 @@ namespace Microsoft.DotNet.Cli
|
|||
.Select(r => r.Include) ??
|
||||
Empty<string>();
|
||||
|
||||
public static IEnumerable<string> ConfigurationsFromProjectFileOrDefaults() =>
|
||||
GetMSBuildProject()
|
||||
?.GetConfigurations() ??
|
||||
new[] { "Debug", "Release" };
|
||||
|
||||
private static MsbuildProject GetMSBuildProject()
|
||||
{
|
||||
try
|
||||
|
|
Loading…
Reference in a new issue