Skip to content
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

Add --ucr shorthand for --use-current-runtime #27971

Merged
merged 1 commit into from
Oct 12, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 13 additions & 11 deletions src/Cli/dotnet/CommonOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@ internal static class CommonOptions
IsHidden = true
}.ForwardAsProperty()
.AllowSingleArgPerToken();

public static Option<VerbosityOptions> VerbosityOption =
new ForwardedOption<VerbosityOptions>(
new string[] { "-v", "--verbosity" },
description: CommonLocalizableStrings.VerbosityOptionDescription)
{
ArgumentHelpName = CommonLocalizableStrings.LevelArgumentName
}.ForwardAsSingle(o => $"-verbosity:{o}");
{
ArgumentHelpName = CommonLocalizableStrings.LevelArgumentName
}.ForwardAsSingle(o => $"-verbosity:{o}");

public static Option<VerbosityOptions> HiddenVerbosityOption =
new ForwardedOption<VerbosityOptions>(
Expand All @@ -47,15 +47,15 @@ public static Option<string> FrameworkOption(string description) =>
description)
{
ArgumentHelpName = CommonLocalizableStrings.FrameworkArgumentName

}.ForwardAsSingle(o => $"-property:TargetFramework={o}")
.AddCompletions(Complete.TargetFrameworksFromProjectFile);

private static string RuntimeArgName = CommonLocalizableStrings.RuntimeIdentifierArgumentName;
private static Func<string, IEnumerable<string>> RuntimeArgFunc = o => new string[] { $"-property:RuntimeIdentifier={o}", "-property:_CommandLineDefinedRuntimeIdentifier=true" };
private static CompletionDelegate RuntimeCompletions = Complete.RunTimesFromProjectFile;
public static Option<string> RuntimeOption =

public static Option<string> RuntimeOption =
new ForwardedOption<string>(
new string[] { "-r", "--runtime" })
{
Expand All @@ -72,7 +72,9 @@ public static Option<string> FrameworkOption(string description) =>
.AddCompletions(RuntimeCompletions);

public static Option<bool> CurrentRuntimeOption(string description) =>
new ForwardedOption<bool>("--use-current-runtime", description)
new ForwardedOption<bool>(
new string[] { "--ucr", "--use-current-runtime" },
description)
.ForwardAs("-property:UseCurrentRuntimeIdentifier=True");

public static Option<string> ConfigurationOption(string description) =>
Expand Down Expand Up @@ -156,7 +158,7 @@ internal static string ArchOptionValue(ParseResult parseResult) =>
"--no-self-contained",
CommonLocalizableStrings.FrameworkDependentOptionDescription)
// Flip the argument so that if this option is specified we get selfcontained=false
.SetForwardingFunction((arg, p) => ForwardSelfContainedOptions(!arg, p));
.SetForwardingFunction((arg, p) => ForwardSelfContainedOptions(!arg, p));

public static readonly Option<string> TestPlatformOption = new Option<string>("--Platform");

Expand Down Expand Up @@ -184,7 +186,7 @@ internal static IEnumerable<string> ResolveArchOptionToRuntimeIdentifier(string
// ResolveOsOptionToRuntimeIdentifier handles resolving the RID when both arch and os are specified
return Array.Empty<string>();
}

var selfContainedSpecified = parseResult.HasOption(SelfContainedOption) || parseResult.HasOption(NoSelfContainedOption);
return ResolveRidShorthandOptions(null, arg, selfContainedSpecified);
}
Expand Down Expand Up @@ -231,7 +233,7 @@ public static string GetDotnetExeDirectory()

var dotnetRootPath = Path.GetDirectoryName(Environment.ProcessPath);
// When running under test the path does not always contain "dotnet".
// The sdk folder is /d/ when run on helix because of space issues
// The sdk folder is /d/ when run on helix because of space issues
dotnetRootPath = Path.GetFileName(dotnetRootPath).Contains("dotnet") || Path.GetFileName(dotnetRootPath).Contains("x64") || Path.GetFileName(dotnetRootPath).Equals("d") ? dotnetRootPath : Path.Combine(dotnetRootPath, "dotnet");
return dotnetRootPath;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ public class GivenDotnetBuildInvocation : IClassFixture<NullCurrentSessionIdFixt
[InlineData(new string[] { "-r", "rid" }, "-property:RuntimeIdentifier=rid -property:_CommandLineDefinedRuntimeIdentifier=true")]
[InlineData(new string[] { "--runtime", "rid" }, "-property:RuntimeIdentifier=rid -property:_CommandLineDefinedRuntimeIdentifier=true")]
[InlineData(new string[] { "--use-current-runtime" }, "-property:UseCurrentRuntimeIdentifier=True")]
[InlineData(new string[] { "--ucr" }, "-property:UseCurrentRuntimeIdentifier=True")]
[InlineData(new string[] { "-c", "config" }, "-property:Configuration=config")]
[InlineData(new string[] { "--configuration", "config" }, "-property:Configuration=config")]
[InlineData(new string[] { "--version-suffix", "mysuffix" }, "-property:VersionSuffix=mysuffix")]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ public GivenDotnetPublishInvocation(ITestOutputHelper output)
[InlineData(new string[] { "-r", "<rid>" }, "-property:RuntimeIdentifier=<rid> -property:_CommandLineDefinedRuntimeIdentifier=true")]
[InlineData(new string[] { "--runtime", "<rid>" }, "-property:RuntimeIdentifier=<rid> -property:_CommandLineDefinedRuntimeIdentifier=true")]
[InlineData(new string[] { "--use-current-runtime" }, "-property:UseCurrentRuntimeIdentifier=True")]
[InlineData(new string[] { "--ucr" }, "-property:UseCurrentRuntimeIdentifier=True")]
[InlineData(new string[] { "-o", "<publishdir>" }, "-property:PublishDir=<cwd><publishdir>")]
[InlineData(new string[] { "--output", "<publishdir>" }, "-property:PublishDir=<cwd><publishdir>")]
[InlineData(new string[] { "-c", "<config>" }, "-property:Configuration=<config>")]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ public void ItAddsProjectToMsbuildInvocation(string optionName)
[InlineData(new string[] { "-r", "<rid>" }, @"-property:RuntimeIdentifier=<rid> -property:_CommandLineDefinedRuntimeIdentifier=true")]
[InlineData(new string[] { "--runtime", "<rid>" }, @"-property:RuntimeIdentifier=<rid> -property:_CommandLineDefinedRuntimeIdentifier=true")]
[InlineData(new string[] { "--use-current-runtime" }, "-property:UseCurrentRuntimeIdentifier=True")]
[InlineData(new string[] { "--ucr" }, "-property:UseCurrentRuntimeIdentifier=True")]
[InlineData(new string[] { "--manifest", "one.xml", "--manifest", "two.xml", "--manifest", "three.xml" }, @"-property:AdditionalProjects=<cwd>one.xml%3B<cwd>two.xml%3B<cwd>three.xml")]
public void MsbuildInvocationIsCorrect(string[] args, string expectedAdditionalArgs)
{
Expand Down