This commit is contained in:
Kudzu 2017-06-22 19:56:13 -04:00
parent 906ce5455b
commit bcfccbf861
2 changed files with 20 additions and 27 deletions

View file

@ -3,9 +3,7 @@ using System.Collections.Generic;
using System.Diagnostics; using System.Diagnostics;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using Microsoft.Win32; using Microsoft.Win32;
using Cosmos.Build.Installer; using Cosmos.Build.Installer;
namespace Cosmos.Build.Builder { namespace Cosmos.Build.Builder {
@ -52,10 +50,12 @@ namespace Cosmos.Build.Builder {
private void CleanDirectory(string aName, string aPath) { private void CleanDirectory(string aName, string aPath) {
if (Directory.Exists(aPath)) { if (Directory.Exists(aPath)) {
Section("Cleaning up " + aName + " directory"); Section("Cleaning up " + aName + " directory");
Echo(" " + aPath);
Directory.Delete(aPath, true); Directory.Delete(aPath, true);
} else {
Section("Creating " + aName + " directory");
Directory.CreateDirectory(aPath);
} }
Log.WriteLine(" " + aPath);
} }
protected override List<string> DoRun() { protected override List<string> DoRun() {
@ -104,7 +104,7 @@ namespace Cosmos.Build.Builder {
protected void CheckIfBuilderRunning() { protected void CheckIfBuilderRunning() {
//Check for builder process //Check for builder process
Echo("Checking if Builder is already running."); Log.WriteLine("Checking if Builder is already running.");
// Check > 1 so we exclude ourself. // Check > 1 so we exclude ourself.
if (NumProcessesContainingName("Cosmos.Build.Builder") > 1) { if (NumProcessesContainingName("Cosmos.Build.Builder") > 1) {
throw new Exception("Another instance of builder is running."); throw new Exception("Another instance of builder is running.");
@ -112,7 +112,7 @@ namespace Cosmos.Build.Builder {
} }
protected void CheckIfUserKitRunning() { protected void CheckIfUserKitRunning() {
Echo("Check if User Kit Installer is already running."); Log.WriteLine("Check if User Kit Installer is already running.");
if (NumProcessesContainingName("CosmosUserKit") > 0) { if (NumProcessesContainingName("CosmosUserKit") > 0) {
throw new Exception("Another instance of the user kit installer is running."); throw new Exception("Another instance of the user kit installer is running.");
} }
@ -122,12 +122,12 @@ namespace Cosmos.Build.Builder {
int xSeconds = 500; int xSeconds = 500;
if (Debugger.IsAttached) { if (Debugger.IsAttached) {
Echo("Checking if Visual Studio is running is ignored by debugging of Builder."); Log.WriteLine("Checking if Visual Studio is running is ignored by debugging of Builder.");
} else { } else {
Echo("Checking if Visual Studio is running."); Log.WriteLine("Checking if Visual Studio is running.");
if (IsRunning("devenv")) { if (IsRunning("devenv")) {
Echo("--Visual Studio is running."); Log.WriteLine("--Visual Studio is running.");
Echo("--Waiting " + xSeconds + " seconds to see if Visual Studio exits."); Log.WriteLine("--Waiting " + xSeconds + " seconds to see if Visual Studio exits.");
// VS doesnt exit right away and user can try devkit again after VS window has closed but is still running. // VS doesnt exit right away and user can try devkit again after VS window has closed but is still running.
// So we wait a few seconds first. // So we wait a few seconds first.
if (WaitForExit("devenv", xSeconds * 1000)) { if (WaitForExit("devenv", xSeconds * 1000)) {
@ -157,7 +157,7 @@ namespace Cosmos.Build.Builder {
} }
private void CheckForInno() { private void CheckForInno() {
Echo("Checking for Inno Setup"); Log.WriteLine("Checking for Inno Setup");
using (var xKey = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Inno Setup 5_is1", false)) { using (var xKey = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Inno Setup 5_is1", false)) {
if (xKey == null) { if (xKey == null) {
mExceptionList.Add("Cannot find Inno Setup."); mExceptionList.Add("Cannot find Inno Setup.");
@ -172,7 +172,7 @@ namespace Cosmos.Build.Builder {
} }
} }
Echo("Checking for Inno Preprocessor"); Log.WriteLine("Checking for Inno Preprocessor");
if (!File.Exists(Path.Combine(mInnoPath, "ISPP.dll"))) { if (!File.Exists(Path.Combine(mInnoPath, "ISPP.dll"))) {
mExceptionList.Add("Inno Preprocessor not detected."); mExceptionList.Add("Inno Preprocessor not detected.");
mBuildState = BuildState.PrerequisiteMissing; mBuildState = BuildState.PrerequisiteMissing;
@ -181,7 +181,7 @@ namespace Cosmos.Build.Builder {
} }
private void CheckForNetCore() { private void CheckForNetCore() {
Echo("Checking for .NET Core"); Log.WriteLine("Checking for .NET Core");
if (!Paths.VSInstancePackages.Contains("Microsoft.VisualStudio.Workload.NetCoreTools")) { if (!Paths.VSInstancePackages.Contains("Microsoft.VisualStudio.Workload.NetCoreTools")) {
mExceptionList.Add(".NET Core not detected."); mExceptionList.Add(".NET Core not detected.");
@ -190,7 +190,7 @@ namespace Cosmos.Build.Builder {
} }
private void CheckForVisualStudioExtensionTools() { private void CheckForVisualStudioExtensionTools() {
Echo("Checking for Visual Studio Extension Tools"); Log.WriteLine("Checking for Visual Studio Extension Tools");
if (!Paths.VSInstancePackages.Contains("Microsoft.VisualStudio.Workload.VisualStudioExtension")) { if (!Paths.VSInstancePackages.Contains("Microsoft.VisualStudio.Workload.VisualStudioExtension")) {
mExceptionList.Add("Visual Studio Extension tools not detected."); mExceptionList.Add("Visual Studio Extension tools not detected.");
@ -307,7 +307,7 @@ namespace Cosmos.Build.Builder {
if (App.UseVsHive) { if (App.UseVsHive) {
vsVersionConfiguration += "Exp"; vsVersionConfiguration += "Exp";
} }
Echo($" {xISCC} /Q {Quoted(mInnoFile)} /dBuildConfiguration={xCfg} /dVSVersion={vsVersionConfiguration} /dVSPath={Quoted(Paths.VSPath)} /dChangeSetVersion={Quoted(mReleaseNo.ToString())}"); Log.WriteLine($" {xISCC} /Q {Quoted(mInnoFile)} /dBuildConfiguration={xCfg} /dVSVersion={vsVersionConfiguration} /dVSPath={Quoted(Paths.VSPath)} /dChangeSetVersion={Quoted(mReleaseNo.ToString())}");
StartConsole(xISCC, $"/Q {Quoted(mInnoFile)} /dBuildConfiguration={xCfg} /dVSVersion={vsVersionConfiguration} /dVSPath={Quoted(Paths.VSPath)} /dChangeSetVersion={Quoted(mReleaseNo.ToString())}"); StartConsole(xISCC, $"/Q {Quoted(mInnoFile)} /dBuildConfiguration={xCfg} /dVSVersion={vsVersionConfiguration} /dVSPath={Quoted(Paths.VSPath)} /dChangeSetVersion={Quoted(mReleaseNo.ToString())}");
} }
@ -321,11 +321,11 @@ namespace Cosmos.Build.Builder {
} }
if (App.ResetHive) { if (App.ResetHive) {
Echo("Resetting hive"); Log.WriteLine("Resetting hive");
Start(xVisualStudio, @"/setup /rootsuffix Exp /ranu"); Start(xVisualStudio, @"/setup /rootsuffix Exp /ranu");
} }
Echo("Launching Visual Studio"); Log.WriteLine("Launching Visual Studio");
Start(xVisualStudio, Quoted(mCosmosPath + @"Cosmos.sln"), false, true); Start(xVisualStudio, Quoted(mCosmosPath + @"Cosmos.sln"), false, true);
} }
@ -348,15 +348,15 @@ namespace Cosmos.Build.Builder {
// Some slow user PCs take around 5 seconds to start up the task... // Some slow user PCs take around 5 seconds to start up the task...
int xSeconds = 10; int xSeconds = 10;
var xTimed = DateTime.Now; var xTimed = DateTime.Now;
Echo("Waiting " + xSeconds + " seconds for Setup to start."); Log.WriteLine("Waiting " + xSeconds + " seconds for Setup to start.");
if (WaitForStart(setupName, xSeconds * 1000)) { if (WaitForStart(setupName, xSeconds * 1000)) {
mExceptionList.Add("Setup did not start."); mExceptionList.Add("Setup did not start.");
return; return;
} }
Echo("Setup is running. " + DateTime.Now.Subtract(xTimed).ToString(@"ss\.fff")); Log.WriteLine("Setup is running. " + DateTime.Now.Subtract(xTimed).ToString(@"ss\.fff"));
// Scheduler starts it and exits, but we need to wait for the setup itself to exit before proceding // Scheduler starts it and exits, but we need to wait for the setup itself to exit before proceding
Echo("Waiting for Setup to complete."); Log.WriteLine("Waiting for Setup to complete.");
WaitForExit(setupName); WaitForExit(setupName);
} else { } else {
Start(mCosmosPath + @"Setup\Output\" + setupName + ".exe", @"/SILENT"); Start(mCosmosPath + @"Setup\Output\" + setupName + ".exe", @"/SILENT");

View file

@ -139,12 +139,5 @@ namespace Cosmos.Build.Installer {
return "\"" + aValue + "\""; return "\"" + aValue + "\"";
} }
public void Echo() {
Echo("");
}
public void Echo(string aText) {
Log.WriteLine(aText);
}
} }
} }