Skip to content

Commit

Permalink
Add --infer-runtime option
Browse files Browse the repository at this point in the history
  • Loading branch information
am11 committed Oct 10, 2020
1 parent ba65b48 commit 95a7343
Show file tree
Hide file tree
Showing 34 changed files with 165 additions and 5 deletions.
8 changes: 8 additions & 0 deletions src/Cli/dotnet/CommonOptions.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices;
using Microsoft.DotNet.Cli.CommandLine;
using Microsoft.DotNet.Tools.Common;
using Microsoft.DotNet.Tools;
Expand Down Expand Up @@ -49,6 +50,13 @@ public static Option RuntimeOption(string description, bool withShortOption = tr
.With(name: CommonLocalizableStrings.RuntimeIdentifierArgumentName)
.ForwardAsSingle(o => $"-property:RuntimeIdentifier={o.Arguments.Single()}"));

public static Option InferRuntimeOption(string description, bool withShortOption = true) =>
Create.Option(
"--infer-runtime",
description,
Accept.NoArguments()
.ForwardAs($"-property:RuntimeIdentifier={RuntimeInformation.RuntimeIdentifier}"));

public static Option ConfigurationOption(string description) =>
Create.Option(
"-c|--configuration",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,9 @@
<data name="CmdRuntimeOptionDescription" xml:space="preserve">
<value>The target runtime to restore packages for.</value>
</data>
<data name="CmdInferRuntimeOptionDescription" xml:space="preserve">
<value>Use host runtime to build the target.</value>
</data>
<data name="CmdPackagesOption" xml:space="preserve">
<value>PACKAGES_DIR</value>
</data>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System.Collections.Generic;
using System.Linq;
using System.Reflection.Metadata;
using System.Runtime.InteropServices;
using Microsoft.DotNet.Cli.CommandLine;
using Microsoft.DotNet.Tools;
using LocalizableStrings = Microsoft.DotNet.Tools.Restore.LocalizableStrings;
Expand Down Expand Up @@ -83,6 +84,11 @@ private static Option[] ImplicitRestoreOptions(bool showHelp = false, bool useSh
.WithSuggestionsFrom(_ => Suggest.RunTimesFromProjectFile())
.With(name: LocalizableStrings.CmdRuntimeOption)
.ForwardAsSingle(o => $"-property:RuntimeIdentifiers={string.Join("%3B", o.Arguments)}")),
Create.Option(
"--infer-runtime",
LocalizableStrings.CmdInferRuntimeOptionDescription,
Accept.NoArguments()
.ForwardAs($"-property:RuntimeIdentifier={RuntimeInformation.RuntimeIdentifier}")),
Create.Option(
"--packages",
showHelp ? LocalizableStrings.CmdPackagesOptionDescription : string.Empty,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@
<target state="translated">Volitelná cesta k souboru projektu nebo k argumentům MSBuildu</target>
<note />
</trans-unit>
<trans-unit id="CmdInferRuntimeOptionDescription">
<source>Use host runtime to build the target.</source>
<target state="new">Use host runtime to build the target.</target>
<note />
</trans-unit>
<trans-unit id="CmdSourceOption">
<source>SOURCE</source>
<target state="translated">SOURCE</target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@
<target state="translated">Optionaler Pfad zu einer Projektdatei oder MSBuild-Argumente.</target>
<note />
</trans-unit>
<trans-unit id="CmdInferRuntimeOptionDescription">
<source>Use host runtime to build the target.</source>
<target state="new">Use host runtime to build the target.</target>
<note />
</trans-unit>
<trans-unit id="CmdSourceOption">
<source>SOURCE</source>
<target state="translated">SOURCE</target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@
<target state="translated">Ruta de acceso opcional a un archivo de proyecto o argumentos de MSBuild.</target>
<note />
</trans-unit>
<trans-unit id="CmdInferRuntimeOptionDescription">
<source>Use host runtime to build the target.</source>
<target state="new">Use host runtime to build the target.</target>
<note />
</trans-unit>
<trans-unit id="CmdSourceOption">
<source>SOURCE</source>
<target state="translated">ORIGEN</target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@
<target state="translated">Chemin facultatif vers un fichier projet ou des arguments MSBuild.</target>
<note />
</trans-unit>
<trans-unit id="CmdInferRuntimeOptionDescription">
<source>Use host runtime to build the target.</source>
<target state="new">Use host runtime to build the target.</target>
<note />
</trans-unit>
<trans-unit id="CmdSourceOption">
<source>SOURCE</source>
<target state="translated">SOURCE</target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@
<target state="translated">Percorso facoltativo di un file di progetto o di argomenti di MSBuild.</target>
<note />
</trans-unit>
<trans-unit id="CmdInferRuntimeOptionDescription">
<source>Use host runtime to build the target.</source>
<target state="new">Use host runtime to build the target.</target>
<note />
</trans-unit>
<trans-unit id="CmdSourceOption">
<source>SOURCE</source>
<target state="translated">ORIGINE</target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@
<target state="translated">プロジェクト ファイルまたは MSBuild 引数へのオプションのパス。</target>
<note />
</trans-unit>
<trans-unit id="CmdInferRuntimeOptionDescription">
<source>Use host runtime to build the target.</source>
<target state="new">Use host runtime to build the target.</target>
<note />
</trans-unit>
<trans-unit id="CmdSourceOption">
<source>SOURCE</source>
<target state="translated">SOURCE</target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@
<target state="translated">프로젝트 파일의 선택적 경로 또는 MSBuild 인수입니다.</target>
<note />
</trans-unit>
<trans-unit id="CmdInferRuntimeOptionDescription">
<source>Use host runtime to build the target.</source>
<target state="new">Use host runtime to build the target.</target>
<note />
</trans-unit>
<trans-unit id="CmdSourceOption">
<source>SOURCE</source>
<target state="translated">SOURCE</target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@
<target state="translated">Opcjonalna ścieżka do pliku projektu lub argumentów programu MSBuild.</target>
<note />
</trans-unit>
<trans-unit id="CmdInferRuntimeOptionDescription">
<source>Use host runtime to build the target.</source>
<target state="new">Use host runtime to build the target.</target>
<note />
</trans-unit>
<trans-unit id="CmdSourceOption">
<source>SOURCE</source>
<target state="translated">ŹRÓDŁO</target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@
<target state="translated">Caminho opcional para um arquivo de projeto ou argumentos do MSBuild.</target>
<note />
</trans-unit>
<trans-unit id="CmdInferRuntimeOptionDescription">
<source>Use host runtime to build the target.</source>
<target state="new">Use host runtime to build the target.</target>
<note />
</trans-unit>
<trans-unit id="CmdSourceOption">
<source>SOURCE</source>
<target state="translated">ORIGEM</target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@
<target state="translated">Дополнительный путь к файлу проекта или аргументам MSBuild.</target>
<note />
</trans-unit>
<trans-unit id="CmdInferRuntimeOptionDescription">
<source>Use host runtime to build the target.</source>
<target state="new">Use host runtime to build the target.</target>
<note />
</trans-unit>
<trans-unit id="CmdSourceOption">
<source>SOURCE</source>
<target state="translated">SOURCE</target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@
<target state="translated">Proje dosyasının veya MSBuild bağımsız değişkenlerinin isteğe bağlı yolu.</target>
<note />
</trans-unit>
<trans-unit id="CmdInferRuntimeOptionDescription">
<source>Use host runtime to build the target.</source>
<target state="new">Use host runtime to build the target.</target>
<note />
</trans-unit>
<trans-unit id="CmdSourceOption">
<source>SOURCE</source>
<target state="translated">SOURCE</target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@
<target state="translated">项目文件或 MSBuild 参数的可选路径。</target>
<note />
</trans-unit>
<trans-unit id="CmdInferRuntimeOptionDescription">
<source>Use host runtime to build the target.</source>
<target state="new">Use host runtime to build the target.</target>
<note />
</trans-unit>
<trans-unit id="CmdSourceOption">
<source>SOURCE</source>
<target state="translated">SOURCE</target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@
<target state="translated">專案檔或 MSBuild 引數的選擇性路徑。</target>
<note />
</trans-unit>
<trans-unit id="CmdInferRuntimeOptionDescription">
<source>Use host runtime to build the target.</source>
<target state="new">Use host runtime to build the target.</target>
<note />
</trans-unit>
<trans-unit id="CmdSourceOption">
<source>SOURCE</source>
<target state="translated">SOURCE</target>
Expand Down
5 changes: 4 additions & 1 deletion src/Cli/dotnet/commands/dotnet-store/LocalizableStrings.resx
Original file line number Diff line number Diff line change
Expand Up @@ -162,4 +162,7 @@
<data name="RuntimeOptionDescription" xml:space="preserve">
<value>The target runtime to store packages for.</value>
</data>
</root>
<data name="InferRuntimeOptionDescription" xml:space="preserve">
<value>Use host runtime to build the target.</value>
</data>
</root>
1 change: 1 addition & 0 deletions src/Cli/dotnet/commands/dotnet-store/StoreCommandParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ public static Command Store() =>
.With(name: LocalizableStrings.FrameworkVersionOption)
.ForwardAsSingle(o => $"-property:RuntimeFrameworkVersion={o.Arguments.Single()}")),
CommonOptions.RuntimeOption(LocalizableStrings.RuntimeOptionDescription),
CommonOptions.InferRuntimeOption(LocalizableStrings.InferRuntimeOptionDescription),
Create.Option(
"-o|--output",
LocalizableStrings.OutputOptionDescription,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@
<target state="translated">Uloží určená sestavení pro platformu .NET. Standardně se optimalizují pro cílový modul runtime a architekturu.</target>
<note />
</trans-unit>
<trans-unit id="InferRuntimeOptionDescription">
<source>Use host runtime to build the target.</source>
<target state="new">Use host runtime to build the target.</target>
<note />
</trans-unit>
<trans-unit id="OutputOption">
<source>OUTPUT_DIR</source>
<target state="translated">OUTPUT_DIR</target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@
<target state="translated">Speichert die angegebenen Assemblys für die .NET-Plattform. Standardmäßig werden diese für die Zielruntime und das Framework optimiert.</target>
<note />
</trans-unit>
<trans-unit id="InferRuntimeOptionDescription">
<source>Use host runtime to build the target.</source>
<target state="new">Use host runtime to build the target.</target>
<note />
</trans-unit>
<trans-unit id="OutputOption">
<source>OUTPUT_DIR</source>
<target state="translated">OUTPUT_DIR</target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@
<target state="translated">Almacena los ensamblados especificados para la plataforma .NET. De forma predeterminada, estos se optimizarán para el tiempo de ejecución y la plataforma de destino.</target>
<note />
</trans-unit>
<trans-unit id="InferRuntimeOptionDescription">
<source>Use host runtime to build the target.</source>
<target state="new">Use host runtime to build the target.</target>
<note />
</trans-unit>
<trans-unit id="OutputOption">
<source>OUTPUT_DIR</source>
<target state="translated">DIRECTORIO_DE_SALIDA</target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@
<target state="translated">Stocke les assemblys spécifiés pour la plateforme .NET. Par défaut, ceux-ci sont optimisés pour le runtime et le framework cible.</target>
<note />
</trans-unit>
<trans-unit id="InferRuntimeOptionDescription">
<source>Use host runtime to build the target.</source>
<target state="new">Use host runtime to build the target.</target>
<note />
</trans-unit>
<trans-unit id="OutputOption">
<source>OUTPUT_DIR</source>
<target state="translated">OUTPUT_DIR</target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@
<target state="translated">Consente di archiviare gli assembly specificati per la piattaforma .NET. Per impostazione predefinita, gli assembly verranno ottimizzati per il framework e il runtime di destinazione.</target>
<note />
</trans-unit>
<trans-unit id="InferRuntimeOptionDescription">
<source>Use host runtime to build the target.</source>
<target state="new">Use host runtime to build the target.</target>
<note />
</trans-unit>
<trans-unit id="OutputOption">
<source>OUTPUT_DIR</source>
<target state="translated">DIR_OUTPUT</target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@
<target state="translated">.NET Platform の指定されたアセンブリを格納します。既定では、これらはターゲットのランタイムとフレームワーク用に最適化されます。</target>
<note />
</trans-unit>
<trans-unit id="InferRuntimeOptionDescription">
<source>Use host runtime to build the target.</source>
<target state="new">Use host runtime to build the target.</target>
<note />
</trans-unit>
<trans-unit id="OutputOption">
<source>OUTPUT_DIR</source>
<target state="translated">OUTPUT_DIR</target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@
<target state="translated">.NET 플랫폼에 대해 지정된 어셈블리를 저장합니다. 기본적으로 대상 런타임 및 프레임워크에 대해 최적화됩니다.</target>
<note />
</trans-unit>
<trans-unit id="InferRuntimeOptionDescription">
<source>Use host runtime to build the target.</source>
<target state="new">Use host runtime to build the target.</target>
<note />
</trans-unit>
<trans-unit id="OutputOption">
<source>OUTPUT_DIR</source>
<target state="translated">OUTPUT_DIR</target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@
<target state="translated">Przechowuje określone zestawy platformy .NET. Domyślnie są one optymalizowane pod kątem docelowego środowiska uruchomieniowego i platformy docelowej.</target>
<note />
</trans-unit>
<trans-unit id="InferRuntimeOptionDescription">
<source>Use host runtime to build the target.</source>
<target state="new">Use host runtime to build the target.</target>
<note />
</trans-unit>
<trans-unit id="OutputOption">
<source>OUTPUT_DIR</source>
<target state="translated">KATALOG_WYJŚCIOWY</target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@
<target state="translated">Armazena os assemblies especificados para a Plataforma .NET. Por padrão, serão otimizados para o runtime e a estrutura de destino.</target>
<note />
</trans-unit>
<trans-unit id="InferRuntimeOptionDescription">
<source>Use host runtime to build the target.</source>
<target state="new">Use host runtime to build the target.</target>
<note />
</trans-unit>
<trans-unit id="OutputOption">
<source>OUTPUT_DIR</source>
<target state="translated">OUTPUT_DIR</target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@
<target state="translated">Хранит указанные сборки для платформы .NET. По умолчанию они оптимизируются для целевой среды выполнения и платформы.</target>
<note />
</trans-unit>
<trans-unit id="InferRuntimeOptionDescription">
<source>Use host runtime to build the target.</source>
<target state="new">Use host runtime to build the target.</target>
<note />
</trans-unit>
<trans-unit id="OutputOption">
<source>OUTPUT_DIR</source>
<target state="translated">OUTPUT_DIR</target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@
<target state="translated">.NET Platformu için belirtilen bütünleştirilmiş kodları depolar. Varsayılan olarak, bunlar hedef çalışma zamanı ve çerçeve için iyileştirilir.</target>
<note />
</trans-unit>
<trans-unit id="InferRuntimeOptionDescription">
<source>Use host runtime to build the target.</source>
<target state="new">Use host runtime to build the target.</target>
<note />
</trans-unit>
<trans-unit id="OutputOption">
<source>OUTPUT_DIR</source>
<target state="translated">ÇIKIŞ_DİZİNİ</target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@
<target state="translated">存储为 .NET 平台指定的程序集。默认情况下,这些程序集将针对目标运行时和框架进行优化。</target>
<note />
</trans-unit>
<trans-unit id="InferRuntimeOptionDescription">
<source>Use host runtime to build the target.</source>
<target state="new">Use host runtime to build the target.</target>
<note />
</trans-unit>
<trans-unit id="OutputOption">
<source>OUTPUT_DIR</source>
<target state="translated">OUTPUT_DIR</target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@
<target state="translated">儲存為 .NET 平台所指定的組件。根據預設,會為目標執行階段與架構,最佳化這些組件。</target>
<note />
</trans-unit>
<trans-unit id="InferRuntimeOptionDescription">
<source>Use host runtime to build the target.</source>
<target state="new">Use host runtime to build the target.</target>
<note />
</trans-unit>
<trans-unit id="OutputOption">
<source>OUTPUT_DIR</source>
<target state="translated">OUTPUT_DIR</target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ public class GivenDotnetBuildInvocation : IClassFixture<NullCurrentSessionIdFixt
[InlineData(new string[] { "--no-incremental" }, "-target:Rebuild")]
[InlineData(new string[] { "-r", "rid" }, "-property:RuntimeIdentifier=rid")]
[InlineData(new string[] { "--runtime", "rid" }, "-property:RuntimeIdentifier=rid")]
[InlineData(new string[] { "--infer-runtime" }, "-property:RuntimeIdentifier=<self-rid>")]
[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 All @@ -40,7 +41,8 @@ public void MsbuildInvocationIsCorrect(string[] args, string expectedAdditionalA
{
expectedAdditionalArgs =
(string.IsNullOrEmpty(expectedAdditionalArgs) ? "" : $" {expectedAdditionalArgs}")
.Replace("<cwd>", WorkingDirectory);
.Replace("<cwd>", WorkingDirectory)
.Replace("<self-rid>", RuntimeInformation.RuntimeIdentifier);
var msbuildPath = "<msbuildpath>";
var command = BuildCommand.FromArgs(args, msbuildPath);
Expand Down
Loading

0 comments on commit 95a7343

Please sign in to comment.