From 9b4cb6a0721c31a34e5f74b53d759d813742d289 Mon Sep 17 00:00:00 2001 From: Alex Barney Date: Sun, 18 Dec 2016 22:42:54 -0600 Subject: [PATCH] Add Runtime Identifier option to dotnet-restore * Add an option to specify an RID when restoring * This brings the option from the publish and build command to the restore command --- .../commands/dotnet-restore/LocalizableStrings.cs | 4 ++++ src/dotnet/commands/dotnet-restore/Program.cs | 10 ++++++++++ 2 files changed, 14 insertions(+) diff --git a/src/dotnet/commands/dotnet-restore/LocalizableStrings.cs b/src/dotnet/commands/dotnet-restore/LocalizableStrings.cs index 7b63ee1b7..ac3d8b115 100644 --- a/src/dotnet/commands/dotnet-restore/LocalizableStrings.cs +++ b/src/dotnet/commands/dotnet-restore/LocalizableStrings.cs @@ -14,6 +14,10 @@ public const string CmdSourceOptionDescription = "Specifies a NuGet package source to use during the restore."; + public const string CmdRuntimeOption = "RUNTIME_IDENTIFIER"; + + public const string CmdRuntimeOptionDescription = "Target runtime to restore packages for."; + public const string CmdPackagesOption = "PACKAGES_DIRECTORY"; public const string CmdPackagesOptionDescription = "Directory to install packages in."; diff --git a/src/dotnet/commands/dotnet-restore/Program.cs b/src/dotnet/commands/dotnet-restore/Program.cs index 8d6e1b390..017c764ae 100644 --- a/src/dotnet/commands/dotnet-restore/Program.cs +++ b/src/dotnet/commands/dotnet-restore/Program.cs @@ -35,6 +35,11 @@ namespace Microsoft.DotNet.Tools.Restore LocalizableStrings.CmdSourceOptionDescription, CommandOptionType.MultipleValue); + var runtimeOption = cmd.Option( + $"-r|--runtime <{LocalizableStrings.CmdRuntimeOption}>", + LocalizableStrings.CmdRuntimeOptionDescription, + CommandOptionType.MultipleValue); + var packagesOption = cmd.Option( $"--packages <{LocalizableStrings.CmdPackagesOption}>", LocalizableStrings.CmdPackagesOptionDescription, @@ -81,6 +86,11 @@ namespace Microsoft.DotNet.Tools.Restore msbuildArgs.Add($"/p:RestoreSources={string.Join("%3B", sourceOption.Values)}"); } + if (runtimeOption.HasValue()) + { + msbuildArgs.Add($"/p:RuntimeIdentifiers={string.Join("%3B", runtimeOption.Values)}"); + } + if (packagesOption.HasValue()) { msbuildArgs.Add($"/p:RestorePackagesPath={packagesOption.Value()}");