77using System . Linq ;
88using Microsoft . Build . Evaluation ;
99using Microsoft . DotNet . Cli . Utils ;
10+ using Microsoft . DotNet . Tools ;
1011using Microsoft . DotNet . Tools . MSBuild ;
1112using Microsoft . DotNet . Tools . Run . LaunchSettings ;
1213
@@ -19,6 +20,7 @@ public partial class RunCommand
1920 public bool NoBuild { get ; private set ; }
2021 public string Project { get ; private set ; }
2122 public IReadOnlyCollection < string > Args { get ; private set ; }
23+ public bool NoRestore { get ; private set ; }
2224
2325 private List < string > _args ;
2426 private bool ShouldBuild => ! NoBuild ;
@@ -55,6 +57,7 @@ public RunCommand(string configuration,
5557 string project ,
5658 string launchProfile ,
5759 bool noLaunchProfile ,
60+ bool noRestore ,
5861 IReadOnlyCollection < string > args )
5962 {
6063 Configuration = configuration ;
@@ -64,6 +67,7 @@ public RunCommand(string configuration,
6467 LaunchProfile = launchProfile ;
6568 NoLaunchProfile = noLaunchProfile ;
6669 Args = args ;
70+ NoRestore = noRestore ;
6771 }
6872
6973 public RunCommand MakeNewWithReplaced ( string configuration = null ,
@@ -72,6 +76,7 @@ public RunCommand MakeNewWithReplaced(string configuration = null,
7276 string project = null ,
7377 string launchProfile = null ,
7478 bool ? noLaunchProfile = null ,
79+ bool ? noRestore = null ,
7580 IReadOnlyCollection < string > args = null )
7681 {
7782 return new RunCommand (
@@ -81,6 +86,7 @@ public RunCommand MakeNewWithReplaced(string configuration = null,
8186 project ?? this . Project ,
8287 launchProfile ?? this . LaunchProfile ,
8388 noLaunchProfile ?? this . NoLaunchProfile ,
89+ noRestore ?? this . NoRestore ,
8490 args ?? this . Args
8591 ) ;
8692 }
@@ -142,8 +148,7 @@ private void EnsureProjectIsBuilt()
142148 buildArgs . Add ( $ "/p:TargetFramework={ Framework } ") ;
143149 }
144150
145- var buildResult = new MSBuildForwardingApp ( buildArgs ) . Execute ( ) ;
146-
151+ var buildResult = new RestoringCommand ( buildArgs , NoRestore ) . Execute ( ) ;
147152 if ( buildResult != 0 )
148153 {
149154 Reporter . Error . WriteLine ( ) ;
0 commit comments