Implicit restore for build, pack, publish, run and test.

This commit is contained in:
Livar Cunha 2017-06-01 21:25:06 -07:00
parent a3d6c2a551
commit dd76fec564
13 changed files with 91 additions and 21 deletions

View file

@ -7,6 +7,7 @@ using System.IO;
using System.Linq;
using Microsoft.Build.Evaluation;
using Microsoft.DotNet.Cli.Utils;
using Microsoft.DotNet.Tools;
using Microsoft.DotNet.Tools.MSBuild;
using Microsoft.DotNet.Tools.Run.LaunchSettings;
@ -19,6 +20,7 @@ namespace Microsoft.DotNet.Tools.Run
public bool NoBuild { get; private set; }
public string Project { get; private set; }
public IReadOnlyCollection<string> Args { get; private set; }
public bool NoRestore { get; private set; }
private List<string> _args;
private bool ShouldBuild => !NoBuild;
@ -55,6 +57,7 @@ namespace Microsoft.DotNet.Tools.Run
string project,
string launchProfile,
bool noLaunchProfile,
bool noRestore,
IReadOnlyCollection<string> args)
{
Configuration = configuration;
@ -64,6 +67,7 @@ namespace Microsoft.DotNet.Tools.Run
LaunchProfile = launchProfile;
NoLaunchProfile = noLaunchProfile;
Args = args;
NoRestore = noRestore;
}
public RunCommand MakeNewWithReplaced(string configuration = null,
@ -72,6 +76,7 @@ namespace Microsoft.DotNet.Tools.Run
string project = null,
string launchProfile = null,
bool? noLaunchProfile = null,
bool? noRestore = null,
IReadOnlyCollection<string> args = null)
{
return new RunCommand(
@ -81,6 +86,7 @@ namespace Microsoft.DotNet.Tools.Run
project ?? this.Project,
launchProfile ?? this.LaunchProfile,
noLaunchProfile ?? this.NoLaunchProfile,
noRestore ?? this.NoRestore,
args ?? this.Args
);
}
@ -142,8 +148,7 @@ namespace Microsoft.DotNet.Tools.Run
buildArgs.Add($"/p:TargetFramework={Framework}");
}
var buildResult = new MSBuildForwardingApp(buildArgs).Execute();
var buildResult = new RestoringCommand(buildArgs, NoRestore).Execute();
if (buildResult != 0)
{
Reporter.Error.WriteLine();