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,
|
description,
|
||||||
Accept.ExactlyOneArgument()
|
Accept.ExactlyOneArgument()
|
||||||
.With(name: CommonLocalizableStrings.ConfigurationArgumentName)
|
.With(name: CommonLocalizableStrings.ConfigurationArgumentName)
|
||||||
.WithSuggestionsFrom("Debug", "Release")
|
.WithSuggestionsFrom(_ => Suggest.ConfigurationsFromProjectFileOrDefaults())
|
||||||
.ForwardAsSingle(o => $"-property:Configuration={o.Arguments.Single()}"));
|
.ForwardAsSingle(o => $"-property:Configuration={o.Arguments.Single()}"));
|
||||||
|
|
||||||
public static Option VersionSuffixOption() =>
|
public static Option VersionSuffixOption() =>
|
||||||
|
@ -72,4 +72,4 @@ namespace Microsoft.DotNet.Cli
|
||||||
CommonLocalizableStrings.NoRestoreDescription,
|
CommonLocalizableStrings.NoRestoreDescription,
|
||||||
Accept.NoArguments());
|
Accept.NoArguments());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,6 +25,7 @@ namespace Microsoft.DotNet.Tools
|
||||||
private ProjectCollection _projects;
|
private ProjectCollection _projects;
|
||||||
private List<NuGetFramework> _cachedTfms = null;
|
private List<NuGetFramework> _cachedTfms = null;
|
||||||
private IEnumerable<string> cachedRuntimeIdentifiers;
|
private IEnumerable<string> cachedRuntimeIdentifiers;
|
||||||
|
private IEnumerable<string> cachedConfigurations;
|
||||||
|
|
||||||
private MsbuildProject(ProjectCollection projects, ProjectRootElement project)
|
private MsbuildProject(ProjectCollection projects, ProjectRootElement project)
|
||||||
{
|
{
|
||||||
|
@ -168,6 +169,12 @@ namespace Microsoft.DotNet.Tools
|
||||||
return _cachedTfms;
|
return _cachedTfms;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public IEnumerable<string> GetConfigurations()
|
||||||
|
{
|
||||||
|
return cachedConfigurations ??
|
||||||
|
(cachedConfigurations = GetEvaluatedProject().GetConfigurations());
|
||||||
|
}
|
||||||
|
|
||||||
public bool CanWorkOnFramework(NuGetFramework framework)
|
public bool CanWorkOnFramework(NuGetFramework framework)
|
||||||
{
|
{
|
||||||
foreach (var tfm in GetTargetFrameworks())
|
foreach (var tfm in GetTargetFrameworks())
|
||||||
|
|
|
@ -32,6 +32,11 @@ namespace Microsoft.DotNet.Tools.ProjectExtensions
|
||||||
.Select((frameworkString) => NuGetFramework.Parse(frameworkString));
|
.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)
|
public static IEnumerable<string> GetPropertyCommaSeparatedValues(this Project project, string propertyName)
|
||||||
{
|
{
|
||||||
return project.GetPropertyValue(propertyName)
|
return project.GetPropertyValue(propertyName)
|
||||||
|
|
|
@ -40,6 +40,11 @@ namespace Microsoft.DotNet.Cli
|
||||||
.Select(r => r.Include) ??
|
.Select(r => r.Include) ??
|
||||||
Empty<string>();
|
Empty<string>();
|
||||||
|
|
||||||
|
public static IEnumerable<string> ConfigurationsFromProjectFileOrDefaults() =>
|
||||||
|
GetMSBuildProject()
|
||||||
|
?.GetConfigurations() ??
|
||||||
|
new[] { "Debug", "Release" };
|
||||||
|
|
||||||
private static MsbuildProject GetMSBuildProject()
|
private static MsbuildProject GetMSBuildProject()
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
@ -55,4 +60,4 @@ namespace Microsoft.DotNet.Cli
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue