diff --git a/src/dotnet/commands/dotnet-run3/Program.cs b/src/dotnet/commands/dotnet-run3/Program.cs index 90775bd68..13c564f3b 100644 --- a/src/dotnet/commands/dotnet-run3/Program.cs +++ b/src/dotnet/commands/dotnet-run3/Program.cs @@ -21,14 +21,22 @@ namespace Microsoft.DotNet.Tools.Run app.AllowArgumentSeparator = true; app.HelpOption("-h|--help"); - CommandOption configuration = app.Option("-c|--configuration", "Configuration under which to build", CommandOptionType.SingleValue); - CommandOption project = app.Option("-p|--project", "The path to the project file to run (defaults to the current directory if there is only one project).", CommandOptionType.SingleValue); + CommandOption configuration = app.Option( + "-c|--configuration", "Configuration under which to build", + CommandOptionType.SingleValue); + CommandOption framework = app.Option( + "-f|--framework ", "Compile a specific framework", + CommandOptionType.SingleValue); + CommandOption project = app.Option( + "-p|--project", "The path to the project file to run (defaults to the current directory if there is only one project).", + CommandOptionType.SingleValue); app.OnExecute(() => { Run3Command runCmd = new Run3Command(); runCmd.Configuration = configuration.Value(); + runCmd.Framework = framework.Value(); runCmd.Project = project.Value(); runCmd.Args = app.RemainingArguments; diff --git a/src/dotnet/commands/dotnet-run3/Run3Command.cs b/src/dotnet/commands/dotnet-run3/Run3Command.cs index c5e4f29db..c7c3ee09f 100644 --- a/src/dotnet/commands/dotnet-run3/Run3Command.cs +++ b/src/dotnet/commands/dotnet-run3/Run3Command.cs @@ -14,6 +14,7 @@ namespace Microsoft.DotNet.Tools.Run public partial class Run3Command { public string Configuration { get; set; } + public string Framework { get; set; } public string Project { get; set; } public IReadOnlyList Args { get; set; } @@ -48,6 +49,11 @@ namespace Microsoft.DotNet.Tools.Run buildArgs.Add($"/p:Configuration={Configuration}"); } + if (!string.IsNullOrWhiteSpace(Framework)) + { + buildArgs.Add($"/p:TargetFramework={Framework}"); + } + var buildResult = new MSBuildForwardingApp(buildArgs).Execute(); if (buildResult != 0) @@ -69,6 +75,11 @@ namespace Microsoft.DotNet.Tools.Run globalProperties.Add("Configuration", Configuration); } + if (!string.IsNullOrWhiteSpace(Framework)) + { + globalProperties.Add("TargetFramework", Framework); + } + ProjectInstance projectInstance = new ProjectInstance(Project, globalProperties, null); string runProgram = projectInstance.GetPropertyValue("RunCommand");