using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Diagnostics;
using NodeStarterTools.SolutionPaths;
using NodeStarterTools.BuildWorker;
namespaceNodeStarterTools
{
///<summary>/// dev or build/// if (build) copy bundle to mvc///</summary>classProgram
{
staticreadonly Config Config = new Config();
///<summary>/// Запускает webpack dev server///</summary>staticvoidDebug(bool RunFromVSBuild)
{
//Запущен при старте либо при сборкеif (!RunFromVSBuild)
{
Console.WriteLine("Run from debug VS");
//Проверка, что webpack dev server уже запущенswitch (Config.DebugDevMode)
{
case EnumDevMode.NoCheckExists:
Console.WriteLine("EnumDevMode.NoCheckExists");
new DebugWorker(Config).Work();
break;
case EnumDevMode.IfExistsNoRun:
Console.WriteLine("EnumDevMode.NoCheckExists");
if (Process.GetProcesses().
Where(e => e.MainWindowTitle == "npm").
Count() == 0)
new DebugWorker(Config).Work();
break;
case EnumDevMode.IfExistsReload:
Console.WriteLine("EnumDevMode.IfExistsReload");
Process.GetProcesses().
Where(e => e.MainWindowTitle == "npm").
ToList().ForEach(e => e.CloseMainWindow());
new DebugWorker(Config).Work();
break;
}
}
//запущена при сборкеelse
{
Console.WriteLine("Run from debug build");
}
}
///<summary>/// Запускает сборку бандла///</summary>staticvoidRelease(bool RunFromVSBuild)
{
if (!RunFromVSBuild)
{
Console.WriteLine("Run from release VS");
//Не требуется так как сработает событие окончания сборки//Release();
}
else
{
Console.WriteLine("Run from release build");
new ReleaseWorker(Config).Work();
}
}
staticvoidMain(string[] args)
{
if (!Config.RunSPA)
return;
//true - запущен при сборке из VSbool RunFromVSBuild = args.Length != 0;
#if DEBUG
Debug(RunFromVSBuild);
#else
Release(RunFromVSBuild);
#endif
}
}
}