Skip to content

Commit 347f78f

Browse files
authored
Merge pull request #14093 from am11/feature/add_--infer-runtime_options
Add --use-current-runtime option
2 parents f7144d6 + f346c3d commit 347f78f

36 files changed

+279
-78
lines changed

src/Cli/dotnet/CommonOptions.cs

+13-3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
// Copyright (c) .NET Foundation and contributors. All rights reserved.
2+
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
3+
14
using System;
25
using System.IO;
36
using System.Linq;
@@ -30,7 +33,7 @@ public static Option VerbosityOption(Func<AppliedOption, string> format) =>
3033
"diag", "diagnostic")
3134
.With(name: CommonLocalizableStrings.LevelArgumentName)
3235
.ForwardAsSingle(format));
33-
36+
3437
public static Option FrameworkOption(string description) =>
3538
Create.Option(
3639
"-f|--framework",
@@ -39,7 +42,7 @@ public static Option FrameworkOption(string description) =>
3942
.WithSuggestionsFrom(_ => Suggest.TargetFrameworksFromProjectFile())
4043
.With(name: CommonLocalizableStrings.FrameworkArgumentName)
4144
.ForwardAsSingle(o => $"-property:TargetFramework={o.Arguments.Single()}"));
42-
45+
4346
public static Option RuntimeOption(string description, bool withShortOption = true) =>
4447
Create.Option(
4548
withShortOption ? "-r|--runtime" : "--runtime",
@@ -48,7 +51,14 @@ public static Option RuntimeOption(string description, bool withShortOption = tr
4851
.WithSuggestionsFrom(_ => Suggest.RunTimesFromProjectFile())
4952
.With(name: CommonLocalizableStrings.RuntimeIdentifierArgumentName)
5053
.ForwardAsSingle(o => $"-property:RuntimeIdentifier={o.Arguments.Single()}"));
51-
54+
55+
public static Option CurrentRuntimeOption(string description, bool withShortOption = true) =>
56+
Create.Option(
57+
"--use-current-runtime",
58+
description,
59+
Accept.NoArguments()
60+
.ForwardAs("-property:UseCurrentRuntimeIdentifier=True"));
61+
5262
public static Option ConfigurationOption(string description) =>
5363
Create.Option(
5464
"-c|--configuration",

src/Cli/dotnet/commands/dotnet-restore/LocalizableStrings.resx

+30-27
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<root>
3-
<!--
4-
Microsoft ResX Schema
5-
3+
<!--
4+
Microsoft ResX Schema
5+
66
Version 2.0
7-
8-
The primary goals of this format is to allow a simple XML format
9-
that is mostly human readable. The generation and parsing of the
10-
various data types are done through the TypeConverter classes
7+
8+
The primary goals of this format is to allow a simple XML format
9+
that is mostly human readable. The generation and parsing of the
10+
various data types are done through the TypeConverter classes
1111
associated with the data types.
12-
12+
1313
Example:
14-
14+
1515
... ado.net/XML headers & schema ...
1616
<resheader name="resmimetype">text/microsoft-resx</resheader>
1717
<resheader name="version">2.0</resheader>
@@ -26,36 +26,36 @@
2626
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
2727
<comment>This is a comment</comment>
2828
</data>
29-
30-
There are any number of "resheader" rows that contain simple
29+
30+
There are any number of "resheader" rows that contain simple
3131
name/value pairs.
32-
33-
Each data row contains a name, and value. The row also contains a
34-
type or mimetype. Type corresponds to a .NET class that support
35-
text/value conversion through the TypeConverter architecture.
36-
Classes that don't support this are serialized and stored with the
32+
33+
Each data row contains a name, and value. The row also contains a
34+
type or mimetype. Type corresponds to a .NET class that support
35+
text/value conversion through the TypeConverter architecture.
36+
Classes that don't support this are serialized and stored with the
3737
mimetype set.
38-
39-
The mimetype is used for serialized objects, and tells the
40-
ResXResourceReader how to depersist the object. This is currently not
38+
39+
The mimetype is used for serialized objects, and tells the
40+
ResXResourceReader how to depersist the object. This is currently not
4141
extensible. For a given mimetype the value must be set accordingly:
42-
43-
Note - application/x-microsoft.net.object.binary.base64 is the format
44-
that the ResXResourceWriter will generate, however the reader can
42+
43+
Note - application/x-microsoft.net.object.binary.base64 is the format
44+
that the ResXResourceWriter will generate, however the reader can
4545
read any of the formats listed below.
46-
46+
4747
mimetype: application/x-microsoft.net.object.binary.base64
48-
value : The object must be serialized with
48+
value : The object must be serialized with
4949
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
5050
: and then encoded with base64 encoding.
51-
51+
5252
mimetype: application/x-microsoft.net.object.soap.base64
53-
value : The object must be serialized with
53+
value : The object must be serialized with
5454
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
5555
: and then encoded with base64 encoding.
5656
5757
mimetype: application/x-microsoft.net.object.bytearray.base64
58-
value : The object must be serialized into a byte array
58+
value : The object must be serialized into a byte array
5959
: using a System.ComponentModel.TypeConverter
6060
: and then encoded with base64 encoding.
6161
-->
@@ -141,6 +141,9 @@
141141
<data name="CmdRuntimeOptionDescription" xml:space="preserve">
142142
<value>The target runtime to restore packages for.</value>
143143
</data>
144+
<data name="CmdCurrentRuntimeOptionDescription" xml:space="preserve">
145+
<value>Use current runtime as the target runtime.</value>
146+
</data>
144147
<data name="CmdPackagesOption" xml:space="preserve">
145148
<value>PACKAGES_DIR</value>
146149
</data>

src/Cli/dotnet/commands/dotnet-restore/RestoreCommandParser.cs

+1
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ private static Option[] ImplicitRestoreOptions(bool showHelp = false, bool useSh
8383
.WithSuggestionsFrom(_ => Suggest.RunTimesFromProjectFile())
8484
.With(name: LocalizableStrings.CmdRuntimeOption)
8585
.ForwardAsSingle(o => $"-property:RuntimeIdentifiers={string.Join("%3B", o.Arguments)}")),
86+
CommonOptions.CurrentRuntimeOption(LocalizableStrings.CmdCurrentRuntimeOptionDescription),
8687
Create.Option(
8788
"--packages",
8889
showHelp ? LocalizableStrings.CmdPackagesOptionDescription : string.Empty,

src/Cli/dotnet/commands/dotnet-restore/xlf/LocalizableStrings.cs.xlf

+5
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,11 @@
2222
<target state="translated">Volitelná cesta k souboru projektu nebo k argumentům MSBuildu</target>
2323
<note />
2424
</trans-unit>
25+
<trans-unit id="CmdCurrentRuntimeOptionDescription">
26+
<source>Use current runtime as the target runtime.</source>
27+
<target state="new">Use current runtime as the target runtime.</target>
28+
<note />
29+
</trans-unit>
2530
<trans-unit id="CmdSourceOption">
2631
<source>SOURCE</source>
2732
<target state="translated">SOURCE</target>

src/Cli/dotnet/commands/dotnet-restore/xlf/LocalizableStrings.de.xlf

+5
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,11 @@
2222
<target state="translated">Optionaler Pfad zu einer Projektdatei oder MSBuild-Argumente.</target>
2323
<note />
2424
</trans-unit>
25+
<trans-unit id="CmdCurrentRuntimeOptionDescription">
26+
<source>Use current runtime as the target runtime.</source>
27+
<target state="new">Use current runtime as the target runtime.</target>
28+
<note />
29+
</trans-unit>
2530
<trans-unit id="CmdSourceOption">
2631
<source>SOURCE</source>
2732
<target state="translated">SOURCE</target>

src/Cli/dotnet/commands/dotnet-restore/xlf/LocalizableStrings.es.xlf

+5
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,11 @@
2222
<target state="translated">Ruta de acceso opcional a un archivo de proyecto o argumentos de MSBuild.</target>
2323
<note />
2424
</trans-unit>
25+
<trans-unit id="CmdCurrentRuntimeOptionDescription">
26+
<source>Use current runtime as the target runtime.</source>
27+
<target state="new">Use current runtime as the target runtime.</target>
28+
<note />
29+
</trans-unit>
2530
<trans-unit id="CmdSourceOption">
2631
<source>SOURCE</source>
2732
<target state="translated">SOURCE</target>

src/Cli/dotnet/commands/dotnet-restore/xlf/LocalizableStrings.fr.xlf

+5
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,11 @@
2222
<target state="translated">Chemin facultatif vers un fichier projet ou des arguments MSBuild.</target>
2323
<note />
2424
</trans-unit>
25+
<trans-unit id="CmdCurrentRuntimeOptionDescription">
26+
<source>Use current runtime as the target runtime.</source>
27+
<target state="new">Use current runtime as the target runtime.</target>
28+
<note />
29+
</trans-unit>
2530
<trans-unit id="CmdSourceOption">
2631
<source>SOURCE</source>
2732
<target state="translated">SOURCE</target>

src/Cli/dotnet/commands/dotnet-restore/xlf/LocalizableStrings.it.xlf

+5
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,11 @@
2222
<target state="translated">Percorso facoltativo di un file di progetto o di argomenti di MSBuild.</target>
2323
<note />
2424
</trans-unit>
25+
<trans-unit id="CmdCurrentRuntimeOptionDescription">
26+
<source>Use current runtime as the target runtime.</source>
27+
<target state="new">Use current runtime as the target runtime.</target>
28+
<note />
29+
</trans-unit>
2530
<trans-unit id="CmdSourceOption">
2631
<source>SOURCE</source>
2732
<target state="translated">SOURCE</target>

src/Cli/dotnet/commands/dotnet-restore/xlf/LocalizableStrings.ja.xlf

+5
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,11 @@
2222
<target state="translated">プロジェクト ファイルまたは MSBuild 引数へのオプションのパス。</target>
2323
<note />
2424
</trans-unit>
25+
<trans-unit id="CmdCurrentRuntimeOptionDescription">
26+
<source>Use current runtime as the target runtime.</source>
27+
<target state="new">Use current runtime as the target runtime.</target>
28+
<note />
29+
</trans-unit>
2530
<trans-unit id="CmdSourceOption">
2631
<source>SOURCE</source>
2732
<target state="translated">SOURCE</target>

src/Cli/dotnet/commands/dotnet-restore/xlf/LocalizableStrings.ko.xlf

+5
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,11 @@
2222
<target state="translated">프로젝트 파일의 선택적 경로 또는 MSBuild 인수입니다.</target>
2323
<note />
2424
</trans-unit>
25+
<trans-unit id="CmdCurrentRuntimeOptionDescription">
26+
<source>Use current runtime as the target runtime.</source>
27+
<target state="new">Use current runtime as the target runtime.</target>
28+
<note />
29+
</trans-unit>
2530
<trans-unit id="CmdSourceOption">
2631
<source>SOURCE</source>
2732
<target state="translated">SOURCE</target>

src/Cli/dotnet/commands/dotnet-restore/xlf/LocalizableStrings.pl.xlf

+5
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,11 @@
2222
<target state="translated">Opcjonalna ścieżka do pliku projektu lub argumentów programu MSBuild.</target>
2323
<note />
2424
</trans-unit>
25+
<trans-unit id="CmdCurrentRuntimeOptionDescription">
26+
<source>Use current runtime as the target runtime.</source>
27+
<target state="new">Use current runtime as the target runtime.</target>
28+
<note />
29+
</trans-unit>
2530
<trans-unit id="CmdSourceOption">
2631
<source>SOURCE</source>
2732
<target state="translated">SOURCE</target>

src/Cli/dotnet/commands/dotnet-restore/xlf/LocalizableStrings.pt-BR.xlf

+5
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,11 @@
2222
<target state="translated">Caminho opcional para um arquivo de projeto ou argumentos do MSBuild.</target>
2323
<note />
2424
</trans-unit>
25+
<trans-unit id="CmdCurrentRuntimeOptionDescription">
26+
<source>Use current runtime as the target runtime.</source>
27+
<target state="new">Use current runtime as the target runtime.</target>
28+
<note />
29+
</trans-unit>
2530
<trans-unit id="CmdSourceOption">
2631
<source>SOURCE</source>
2732
<target state="translated">SOURCE</target>

src/Cli/dotnet/commands/dotnet-restore/xlf/LocalizableStrings.ru.xlf

+5
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,11 @@
2222
<target state="translated">Дополнительный путь к файлу проекта или аргументам MSBuild.</target>
2323
<note />
2424
</trans-unit>
25+
<trans-unit id="CmdCurrentRuntimeOptionDescription">
26+
<source>Use current runtime as the target runtime.</source>
27+
<target state="new">Use current runtime as the target runtime.</target>
28+
<note />
29+
</trans-unit>
2530
<trans-unit id="CmdSourceOption">
2631
<source>SOURCE</source>
2732
<target state="translated">SOURCE</target>

src/Cli/dotnet/commands/dotnet-restore/xlf/LocalizableStrings.tr.xlf

+5
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,11 @@
2222
<target state="translated">Proje dosyasının veya MSBuild bağımsız değişkenlerinin isteğe bağlı yolu.</target>
2323
<note />
2424
</trans-unit>
25+
<trans-unit id="CmdCurrentRuntimeOptionDescription">
26+
<source>Use current runtime as the target runtime.</source>
27+
<target state="new">Use current runtime as the target runtime.</target>
28+
<note />
29+
</trans-unit>
2530
<trans-unit id="CmdSourceOption">
2631
<source>SOURCE</source>
2732
<target state="translated">SOURCE</target>

src/Cli/dotnet/commands/dotnet-restore/xlf/LocalizableStrings.zh-Hans.xlf

+5
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,11 @@
2222
<target state="translated">项目文件或 MSBuild 参数的可选路径。</target>
2323
<note />
2424
</trans-unit>
25+
<trans-unit id="CmdCurrentRuntimeOptionDescription">
26+
<source>Use current runtime as the target runtime.</source>
27+
<target state="new">Use current runtime as the target runtime.</target>
28+
<note />
29+
</trans-unit>
2530
<trans-unit id="CmdSourceOption">
2631
<source>SOURCE</source>
2732
<target state="translated">SOURCE</target>

src/Cli/dotnet/commands/dotnet-restore/xlf/LocalizableStrings.zh-Hant.xlf

+5
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,11 @@
2222
<target state="translated">專案檔或 MSBuild 引數的選擇性路徑。</target>
2323
<note />
2424
</trans-unit>
25+
<trans-unit id="CmdCurrentRuntimeOptionDescription">
26+
<source>Use current runtime as the target runtime.</source>
27+
<target state="new">Use current runtime as the target runtime.</target>
28+
<note />
29+
</trans-unit>
2530
<trans-unit id="CmdSourceOption">
2631
<source>SOURCE</source>
2732
<target state="translated">SOURCE</target>

src/Cli/dotnet/commands/dotnet-store/LocalizableStrings.resx

+31-28
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<root>
3-
<!--
4-
Microsoft ResX Schema
5-
3+
<!--
4+
Microsoft ResX Schema
5+
66
Version 2.0
7-
8-
The primary goals of this format is to allow a simple XML format
9-
that is mostly human readable. The generation and parsing of the
10-
various data types are done through the TypeConverter classes
7+
8+
The primary goals of this format is to allow a simple XML format
9+
that is mostly human readable. The generation and parsing of the
10+
various data types are done through the TypeConverter classes
1111
associated with the data types.
12-
12+
1313
Example:
14-
14+
1515
... ado.net/XML headers & schema ...
1616
<resheader name="resmimetype">text/microsoft-resx</resheader>
1717
<resheader name="version">2.0</resheader>
@@ -26,36 +26,36 @@
2626
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
2727
<comment>This is a comment</comment>
2828
</data>
29-
30-
There are any number of "resheader" rows that contain simple
29+
30+
There are any number of "resheader" rows that contain simple
3131
name/value pairs.
32-
33-
Each data row contains a name, and value. The row also contains a
34-
type or mimetype. Type corresponds to a .NET class that support
35-
text/value conversion through the TypeConverter architecture.
36-
Classes that don't support this are serialized and stored with the
32+
33+
Each data row contains a name, and value. The row also contains a
34+
type or mimetype. Type corresponds to a .NET class that support
35+
text/value conversion through the TypeConverter architecture.
36+
Classes that don't support this are serialized and stored with the
3737
mimetype set.
38-
39-
The mimetype is used for serialized objects, and tells the
40-
ResXResourceReader how to depersist the object. This is currently not
38+
39+
The mimetype is used for serialized objects, and tells the
40+
ResXResourceReader how to depersist the object. This is currently not
4141
extensible. For a given mimetype the value must be set accordingly:
42-
43-
Note - application/x-microsoft.net.object.binary.base64 is the format
44-
that the ResXResourceWriter will generate, however the reader can
42+
43+
Note - application/x-microsoft.net.object.binary.base64 is the format
44+
that the ResXResourceWriter will generate, however the reader can
4545
read any of the formats listed below.
46-
46+
4747
mimetype: application/x-microsoft.net.object.binary.base64
48-
value : The object must be serialized with
48+
value : The object must be serialized with
4949
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
5050
: and then encoded with base64 encoding.
51-
51+
5252
mimetype: application/x-microsoft.net.object.soap.base64
53-
value : The object must be serialized with
53+
value : The object must be serialized with
5454
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
5555
: and then encoded with base64 encoding.
5656
5757
mimetype: application/x-microsoft.net.object.bytearray.base64
58-
value : The object must be serialized into a byte array
58+
value : The object must be serialized into a byte array
5959
: using a System.ComponentModel.TypeConverter
6060
: and then encoded with base64 encoding.
6161
-->
@@ -162,4 +162,7 @@
162162
<data name="RuntimeOptionDescription" xml:space="preserve">
163163
<value>The target runtime to store packages for.</value>
164164
</data>
165-
</root>
165+
<data name="CurrentRuntimeOptionDescription" xml:space="preserve">
166+
<value>Use current runtime as the target runtime.</value>
167+
</data>
168+
</root>

src/Cli/dotnet/commands/dotnet-store/StoreCommandParser.cs

+1
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ public static Command Store() =>
5050
.With(name: LocalizableStrings.FrameworkVersionOption)
5151
.ForwardAsSingle(o => $"-property:RuntimeFrameworkVersion={o.Arguments.Single()}")),
5252
CommonOptions.RuntimeOption(LocalizableStrings.RuntimeOptionDescription),
53+
CommonOptions.CurrentRuntimeOption(LocalizableStrings.CurrentRuntimeOptionDescription),
5354
Create.Option(
5455
"-o|--output",
5556
LocalizableStrings.OutputOptionDescription,

0 commit comments

Comments
 (0)