2016-02-02 18:04:50 +00:00
|
|
|
|
using System.IO;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Runtime.InteropServices;
|
|
|
|
|
using Microsoft.DotNet.Cli.Build.Framework;
|
|
|
|
|
using Microsoft.Extensions.PlatformAbstractions;
|
|
|
|
|
|
|
|
|
|
namespace Microsoft.DotNet.Cli.Build
|
|
|
|
|
{
|
2016-03-16 22:54:02 +00:00
|
|
|
|
public class DotNetCli
|
2016-02-02 18:04:50 +00:00
|
|
|
|
{
|
|
|
|
|
public static readonly DotNetCli Stage0 = new DotNetCli(GetStage0Path());
|
2016-03-16 22:54:02 +00:00
|
|
|
|
public static readonly DotNetCli Stage1 = new DotNetCli(Dirs.Stage1);
|
|
|
|
|
public static readonly DotNetCli Stage2 = new DotNetCli(Dirs.Stage2);
|
2016-02-02 18:04:50 +00:00
|
|
|
|
|
|
|
|
|
public string BinPath { get; }
|
|
|
|
|
|
|
|
|
|
public DotNetCli(string binPath)
|
|
|
|
|
{
|
|
|
|
|
BinPath = binPath;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Command Exec(string command, params string[] args)
|
|
|
|
|
{
|
|
|
|
|
return Command.Create(Path.Combine(BinPath, $"dotnet{Constants.ExeSuffix}"), Enumerable.Concat(new[] { command }, args));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Command Restore(params string[] args) => Exec("restore", args);
|
|
|
|
|
public Command Build(params string[] args) => Exec("build", args);
|
|
|
|
|
public Command Pack(params string[] args) => Exec("pack", args);
|
|
|
|
|
public Command Test(params string[] args) => Exec("test", args);
|
|
|
|
|
public Command Publish(params string[] args) => Exec("publish", args);
|
|
|
|
|
|
|
|
|
|
private static string GetStage0Path()
|
|
|
|
|
{
|
|
|
|
|
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
|
|
|
|
|
{
|
2016-02-24 02:04:49 +00:00
|
|
|
|
return Path.Combine(Directory.GetCurrentDirectory(), ".dotnet_stage0",
|
|
|
|
|
PlatformServices.Default.Runtime.OperatingSystemPlatform.ToString(),
|
2016-03-03 19:35:47 +00:00
|
|
|
|
PlatformServices.Default.Runtime.RuntimeArchitecture, "bin");
|
2016-02-02 18:04:50 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2016-03-11 00:39:56 +00:00
|
|
|
|
return Path.Combine(Directory.GetCurrentDirectory(), ".dotnet_stage0", PlatformServices.Default.Runtime.OperatingSystemPlatform.ToString(), "bin");
|
2016-02-02 18:04:50 +00:00
|
|
|
|
}
|
2016-03-03 19:35:47 +00:00
|
|
|
|
|
2016-02-02 18:04:50 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|