diff --git a/build/Microsoft.DotNet.Cli.Prepare.targets b/build/Microsoft.DotNet.Cli.Prepare.targets
index 7de75544f..32321e43d 100644
--- a/build/Microsoft.DotNet.Cli.Prepare.targets
+++ b/build/Microsoft.DotNet.Cli.Prepare.targets
@@ -5,12 +5,13 @@
+
-
+
@@ -20,6 +21,10 @@
+ $(RepoRoot)/.dotnet_stage0/Windows/$(Architecture)
+ $(RepoRoot)/.dotnet_stage0/$(OSName)
+ $(Stage0Path)
+
$(RepoRoot)/artifacts/$(Rid)
$(BaseOutputDirectory)/stage2
$(BaseOutputDirectory)/stage2compilation
@@ -95,4 +100,18 @@
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/build_projects/dotnet-cli-build/DotNetTool.cs b/build_projects/dotnet-cli-build/DotNetTool.cs
new file mode 100644
index 000000000..d3d8581b7
--- /dev/null
+++ b/build_projects/dotnet-cli-build/DotNetTool.cs
@@ -0,0 +1,85 @@
+using Microsoft.Build.Framework;
+using Microsoft.Build.Utilities;
+
+namespace Microsoft.DotNet.Cli.Build
+{
+ public abstract class DotNetTool : ToolTask
+ {
+ private const string ExeName = "dotnet.exe";
+
+ public DotNetTool()
+ {
+ }
+
+ protected abstract string Command { get; }
+
+ protected abstract string Args { get; }
+
+ public string WorkingDirectory { get; set; }
+
+ protected override string ToolName
+ {
+ get { return ExeName; }
+ }
+
+ protected override MessageImportance StandardOutputLoggingImportance
+ {
+ get { return MessageImportance.High; } // or else the output doesn't get logged by default
+ }
+
+ protected override string GenerateFullPathToTool()
+ {
+ string path = ToolPath;
+
+ // if ToolPath was not provided by the MSBuild script
+ if (string.IsNullOrEmpty(path))
+ {
+ Log.LogError($"Could not find the Path to {ExeName}");
+
+ return string.Empty;
+ }
+
+ return path;
+ }
+
+ protected override string GetWorkingDirectory()
+ {
+ return WorkingDirectory ?? base.GetWorkingDirectory();
+ }
+
+ protected override string GenerateCommandLineCommands()
+ {
+ return $"{Command} {Args}";
+ }
+
+ protected override void LogToolCommand(string message)
+ {
+ base.LogToolCommand($"{GetWorkingDirectory()}> {message}");
+ }
+ }
+
+ public class DotNetRestore : DotNetTool
+ {
+ protected override string Command
+ {
+ get { return "restore"; }
+ }
+
+ protected override string Args
+ {
+ get { return $"{GetVerbosity()}"; }
+ }
+
+ public string Verbosity { get; set; }
+
+ private string GetVerbosity()
+ {
+ if (!string.IsNullOrEmpty(Verbosity))
+ {
+ return $"--verbosity {Verbosity}";
+ }
+
+ return null;
+ }
+ }
+}