Adding framework as an option to the run3 verb.

This commit is contained in:
Livar Cunha 2016-09-23 09:23:26 -07:00
parent 13d18f198e
commit f11e555480
2 changed files with 21 additions and 2 deletions

View file

@ -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 <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;

View file

@ -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<string> 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");