Skip to content

Commit 17a4082

Browse files
authored
Merge pull request #27971 from nagilson/nagilson-add-ucr
Add --ucr shorthand for --use-current-runtime
2 parents 72b55a2 + 74e47fe commit 17a4082

File tree

4 files changed

+16
-11
lines changed

4 files changed

+16
-11
lines changed

src/Cli/dotnet/CommonOptions.cs

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,14 @@ internal static class CommonOptions
2323
IsHidden = true
2424
}.ForwardAsProperty()
2525
.AllowSingleArgPerToken();
26-
26+
2727
public static Option<VerbosityOptions> VerbosityOption =
2828
new ForwardedOption<VerbosityOptions>(
2929
new string[] { "-v", "--verbosity" },
3030
description: CommonLocalizableStrings.VerbosityOptionDescription)
31-
{
32-
ArgumentHelpName = CommonLocalizableStrings.LevelArgumentName
33-
}.ForwardAsSingle(o => $"-verbosity:{o}");
31+
{
32+
ArgumentHelpName = CommonLocalizableStrings.LevelArgumentName
33+
}.ForwardAsSingle(o => $"-verbosity:{o}");
3434

3535
public static Option<VerbosityOptions> HiddenVerbosityOption =
3636
new ForwardedOption<VerbosityOptions>(
@@ -47,15 +47,15 @@ public static Option<string> FrameworkOption(string description) =>
4747
description)
4848
{
4949
ArgumentHelpName = CommonLocalizableStrings.FrameworkArgumentName
50-
50+
5151
}.ForwardAsSingle(o => $"-property:TargetFramework={o}")
5252
.AddCompletions(Complete.TargetFrameworksFromProjectFile);
5353

5454
private static string RuntimeArgName = CommonLocalizableStrings.RuntimeIdentifierArgumentName;
5555
private static Func<string, IEnumerable<string>> RuntimeArgFunc = o => new string[] { $"-property:RuntimeIdentifier={o}", "-property:_CommandLineDefinedRuntimeIdentifier=true" };
5656
private static CompletionDelegate RuntimeCompletions = Complete.RunTimesFromProjectFile;
57-
58-
public static Option<string> RuntimeOption =
57+
58+
public static Option<string> RuntimeOption =
5959
new ForwardedOption<string>(
6060
new string[] { "-r", "--runtime" })
6161
{
@@ -72,7 +72,9 @@ public static Option<string> FrameworkOption(string description) =>
7272
.AddCompletions(RuntimeCompletions);
7373

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

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

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

@@ -184,7 +186,7 @@ internal static IEnumerable<string> ResolveArchOptionToRuntimeIdentifier(string
184186
// ResolveOsOptionToRuntimeIdentifier handles resolving the RID when both arch and os are specified
185187
return Array.Empty<string>();
186188
}
187-
189+
188190
var selfContainedSpecified = parseResult.HasOption(SelfContainedOption) || parseResult.HasOption(NoSelfContainedOption);
189191
return ResolveRidShorthandOptions(null, arg, selfContainedSpecified);
190192
}
@@ -231,7 +233,7 @@ public static string GetDotnetExeDirectory()
231233

232234
var dotnetRootPath = Path.GetDirectoryName(Environment.ProcessPath);
233235
// When running under test the path does not always contain "dotnet".
234-
// The sdk folder is /d/ when run on helix because of space issues
236+
// The sdk folder is /d/ when run on helix because of space issues
235237
dotnetRootPath = Path.GetFileName(dotnetRootPath).Contains("dotnet") || Path.GetFileName(dotnetRootPath).Contains("x64") || Path.GetFileName(dotnetRootPath).Equals("d") ? dotnetRootPath : Path.Combine(dotnetRootPath, "dotnet");
236238
return dotnetRootPath;
237239
}

src/Tests/dotnet.Tests/dotnet-msbuild/GivenDotnetBuildInvocation.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ public class GivenDotnetBuildInvocation : IClassFixture<NullCurrentSessionIdFixt
2626
[InlineData(new string[] { "-r", "rid" }, "-property:RuntimeIdentifier=rid -property:_CommandLineDefinedRuntimeIdentifier=true")]
2727
[InlineData(new string[] { "--runtime", "rid" }, "-property:RuntimeIdentifier=rid -property:_CommandLineDefinedRuntimeIdentifier=true")]
2828
[InlineData(new string[] { "--use-current-runtime" }, "-property:UseCurrentRuntimeIdentifier=True")]
29+
[InlineData(new string[] { "--ucr" }, "-property:UseCurrentRuntimeIdentifier=True")]
2930
[InlineData(new string[] { "-c", "config" }, "-property:Configuration=config")]
3031
[InlineData(new string[] { "--configuration", "config" }, "-property:Configuration=config")]
3132
[InlineData(new string[] { "--version-suffix", "mysuffix" }, "-property:VersionSuffix=mysuffix")]

src/Tests/dotnet.Tests/dotnet-msbuild/GivenDotnetPublishInvocation.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ public GivenDotnetPublishInvocation(ITestOutputHelper output)
3030
[InlineData(new string[] { "-r", "<rid>" }, "-property:RuntimeIdentifier=<rid> -property:_CommandLineDefinedRuntimeIdentifier=true")]
3131
[InlineData(new string[] { "--runtime", "<rid>" }, "-property:RuntimeIdentifier=<rid> -property:_CommandLineDefinedRuntimeIdentifier=true")]
3232
[InlineData(new string[] { "--use-current-runtime" }, "-property:UseCurrentRuntimeIdentifier=True")]
33+
[InlineData(new string[] { "--ucr" }, "-property:UseCurrentRuntimeIdentifier=True")]
3334
[InlineData(new string[] { "-o", "<publishdir>" }, "-property:PublishDir=<cwd><publishdir>")]
3435
[InlineData(new string[] { "--output", "<publishdir>" }, "-property:PublishDir=<cwd><publishdir>")]
3536
[InlineData(new string[] { "-c", "<config>" }, "-property:Configuration=<config>")]

src/Tests/dotnet.Tests/dotnet-msbuild/GivenDotnetStoreInvocation.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ public void ItAddsProjectToMsbuildInvocation(string optionName)
3636
[InlineData(new string[] { "-r", "<rid>" }, @"-property:RuntimeIdentifier=<rid> -property:_CommandLineDefinedRuntimeIdentifier=true")]
3737
[InlineData(new string[] { "--runtime", "<rid>" }, @"-property:RuntimeIdentifier=<rid> -property:_CommandLineDefinedRuntimeIdentifier=true")]
3838
[InlineData(new string[] { "--use-current-runtime" }, "-property:UseCurrentRuntimeIdentifier=True")]
39+
[InlineData(new string[] { "--ucr" }, "-property:UseCurrentRuntimeIdentifier=True")]
3940
[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")]
4041
public void MsbuildInvocationIsCorrect(string[] args, string expectedAdditionalArgs)
4142
{

0 commit comments

Comments
 (0)