Merge pull request #1 from sgetaz/Requirements-list

List requirements 1-by-1
This commit is contained in:
sgetaz 2015-08-09 17:32:19 +02:00
commit 1c710704fb
2 changed files with 68 additions and 37 deletions

View file

@ -8,16 +8,25 @@ using System.IO;
using Microsoft.Win32; using Microsoft.Win32;
using System.Windows; using System.Windows;
public enum BuildState
{
CleanupError,
CompilationError,
PrerequisiteMissing,
Running
}
namespace Cosmos.Build.Builder { namespace Cosmos.Build.Builder {
public class CosmosTask : Task { public class CosmosTask : Task {
protected string mCosmosDir; protected string mCosmosDir;
protected string mOutputDir; protected string mOutputDir;
protected BuildState mBuildState;
protected string mAppDataDir; protected string mAppDataDir;
protected int mReleaseNo; protected int mReleaseNo;
protected string mInnoFile; protected string mInnoFile;
protected string mInnoPath; protected string mInnoPath;
// Instead of throwing every exception, we collect them in a list
protected List<string> mExceptionList = new List<string>();
public string InnoScriptTargetFile = "Current.iss"; public string InnoScriptTargetFile = "Current.iss";
public CosmosTask(string aCosmosDir, int aReleaseNo) { public CosmosTask(string aCosmosDir, int aReleaseNo) {
mCosmosDir = aCosmosDir; mCosmosDir = aCosmosDir;
mAppDataDir = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "Cosmos User Kit"); mAppDataDir = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "Cosmos User Kit");
@ -71,26 +80,31 @@ namespace Cosmos.Build.Builder {
} }
} }
protected override void DoRun() { protected override List<string> DoRun() {
mOutputDir = Path.Combine(mCosmosDir, @"Build\VSIP"); mOutputDir = Path.Combine(mCosmosDir, @"Build\VSIP");
if (!App.TestMode) { if (!App.TestMode) {
CheckPrereqs(); //Working CheckPrereqs(); //Working
CleanupVSIPFolder(); // No point in continuing if Prerequisites are missing
// Could potentially add more State checks in the future, but for now
// only the prerequisites are handled...
if (mBuildState != BuildState.PrerequisiteMissing)
{
CleanupVSIPFolder();
CompileCosmos(); //Working CompileCosmos(); //Working
CopyTemplates(); CopyTemplates();
CreateScriptToUseChangesetWhichTaskIsUse(); CreateScriptToUseChangesetWhichTaskIsUse();
CreateSetup(); //Working CreateSetup(); //Working
if (!App.IsUserKit) { if (!App.IsUserKit)
CleanupAlreadyInstalled(); //Working {
RunSetup(); //Working - forgot to run as user kit first CleanupAlreadyInstalled(); //Working
WriteDevKit(); //Working RunSetup(); //Working - forgot to run as user kit first
if (!App.DoNotLaunchVS) { LaunchVS(); } //Working WriteDevKit(); //Working
if (!App.DoNotLaunchVS) { LaunchVS(); } //Working
}
} }
Done(); Done();
} else { } else {
Section("Testing..."); Section("Testing...");
@ -114,6 +128,7 @@ namespace Cosmos.Build.Builder {
//Done(); //Done();
} }
return mExceptionList;
} }
protected void MsBuild(string aSlnFile, string aBuildCfg) { protected void MsBuild(string aSlnFile, string aBuildCfg) {
@ -147,15 +162,16 @@ namespace Cosmos.Build.Builder {
using (var xKey = Registry.LocalMachine.OpenSubKey(aKey + xSubKey)) { using (var xKey = Registry.LocalMachine.OpenSubKey(aKey + xSubKey)) {
string xValue = (string)xKey.GetValue(aValueName); string xValue = (string)xKey.GetValue(aValueName);
if (xValue != null && xValue.ToUpper().Contains(xCheck)) { if (xValue != null && xValue.ToUpper().Contains(xCheck)) {
return true; mBuildState = BuildState.Running;
return true;
} }
} }
} }
if (aCanThrow) { if (aCanThrow) {
NotFound(aCheck); NotFound(aCheck);
} }
return false; return false;
} }
protected void CheckNet35Sp1() { protected void CheckNet35Sp1() {
@ -191,7 +207,7 @@ namespace Cosmos.Build.Builder {
// 6.3 Windows 8 // 6.3 Windows 8
// 6.4 Windows 10 // 6.4 Windows 10
if (xVer < 6.0m) { if (xVer < 6.0m) {
NotFound("Minimum Supported OS is Vista/2008"); NotFound("Minimum Supported OS is Vista/2008");
} }
} }
@ -207,7 +223,7 @@ namespace Cosmos.Build.Builder {
protected void CheckIfUserKitRunning() { protected void CheckIfUserKitRunning() {
Echo("Check if User Kit Installer is already running."); Echo("Check if User Kit Installer is already running.");
if (NumProcessesContainingName("CosmosUserKit") > 1) { if (NumProcessesContainingName("CosmosUserKit") > 1) {
throw new Exception("Another instance of the user kit installer is running."); throw new Exception("Another instance of the user kit installer is running.");
} }
} }
@ -239,7 +255,8 @@ namespace Cosmos.Build.Builder {
} }
protected void NotFound(string aName) { protected void NotFound(string aName) {
throw new Exception("Prerequisite '" + aName + "' not found."); mExceptionList.Add("Prerequisite '" + aName + "' not found.");
mBuildState = BuildState.PrerequisiteMissing;
} }
protected void CheckPrereqs() { protected void CheckPrereqs() {
@ -248,7 +265,8 @@ namespace Cosmos.Build.Builder {
Echo("Checking for x86 run."); Echo("Checking for x86 run.");
if (!AmRunning32Bit()) { if (!AmRunning32Bit()) {
throw new Exception("Builder must run as x86"); mExceptionList.Add("Builder must run as x86");
mBuildState = BuildState.PrerequisiteMissing;
} }
// We assume they have normal .NET stuff if user was able to build the builder... // We assume they have normal .NET stuff if user was able to build the builder...
@ -280,8 +298,9 @@ namespace Cosmos.Build.Builder {
} }
} }
} }
if (!vmWareInstalled && !bochsInstalled) { NotFound("VMWare or Bochs"); } if (!vmWareInstalled && !bochsInstalled) {
NotFound("VMWare or Bochs");
}
// VIX is installed with newer VMware Workstations (8+ for sure). VMware player does not install it? // VIX is installed with newer VMware Workstations (8+ for sure). VMware player does not install it?
// We need to just watch this and adjust as needed. // We need to just watch this and adjust as needed.
//CheckForInstall("VMWare VIX", true); //CheckForInstall("VMWare VIX", true);
@ -325,17 +344,23 @@ namespace Cosmos.Build.Builder {
Echo("Checking for Inno Setup"); Echo("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) {
throw new Exception("Cannot find Inno Setup."); mExceptionList.Add("Cannot find Inno Setup.");
mBuildState = BuildState.PrerequisiteMissing;
return;
} }
mInnoPath = (string)xKey.GetValue("InstallLocation"); mInnoPath = (string)xKey.GetValue("InstallLocation");
if (string.IsNullOrWhiteSpace(mInnoPath)) { if (string.IsNullOrWhiteSpace(mInnoPath)) {
throw new Exception("Cannot find Inno Setup."); mExceptionList.Add("Cannot find Inno Setup.");
mBuildState = BuildState.PrerequisiteMissing;
return;
} }
} }
Echo("Checking for Inno Preprocessor"); Echo("Checking for Inno Preprocessor");
if (!File.Exists(Path.Combine(mInnoPath, "ISPP.dll"))) { if (!File.Exists(Path.Combine(mInnoPath, "ISPP.dll"))) {
throw new Exception("Inno Preprocessor not detected."); mExceptionList.Add("Inno Preprocessor not detected.");
mBuildState = BuildState.PrerequisiteMissing;
return;
} }
} }
@ -347,7 +372,8 @@ namespace Cosmos.Build.Builder {
using (var xKey = Registry.LocalMachine.OpenSubKey(key)) { using (var xKey = Registry.LocalMachine.OpenSubKey(key)) {
string xDir = (string)xKey.GetValue("InstallDir"); string xDir = (string)xKey.GetValue("InstallDir");
if (String.IsNullOrWhiteSpace(xDir)) { if (String.IsNullOrWhiteSpace(xDir)) {
throw new Exception("Visual Studio 2015 RC not detected!"); mExceptionList.Add("Visual Studio 2015 RC not detected!");
mBuildState = BuildState.PrerequisiteMissing;
} }
} }
} }
@ -434,7 +460,8 @@ namespace Cosmos.Build.Builder {
string xISCC = Path.Combine(mInnoPath, "ISCC.exe"); string xISCC = Path.Combine(mInnoPath, "ISCC.exe");
if (!File.Exists(xISCC)) { if (!File.Exists(xISCC)) {
throw new Exception("Cannot find Inno setup."); mExceptionList.Add("Cannot find Inno setup.");
return;
} }
string xCfg = App.IsUserKit ? "UserKit" : "DevKit"; string xCfg = App.IsUserKit ? "UserKit" : "DevKit";
string vsVersionConfiguration = "vs2015"; string vsVersionConfiguration = "vs2015";
@ -459,7 +486,8 @@ namespace Cosmos.Build.Builder {
string xVisualStudio = Paths.VSInstall + @"\devenv.exe"; string xVisualStudio = Paths.VSInstall + @"\devenv.exe";
if (!File.Exists(xVisualStudio)) { if (!File.Exists(xVisualStudio)) {
throw new Exception("Cannot find Visual Studio."); mExceptionList.Add("Cannot find Visual Studio.");
return;
} }
if (App.ResetHive) { if (App.ResetHive) {
@ -489,7 +517,8 @@ namespace Cosmos.Build.Builder {
var xTimed = DateTime.Now; var xTimed = DateTime.Now;
Echo("Waiting " + xSeconds + " seconds for Setup to start."); Echo("Waiting " + xSeconds + " seconds for Setup to start.");
if (WaitForStart(setupName, xSeconds * 1000)) { if (WaitForStart(setupName, xSeconds * 1000)) {
throw new Exception("Setup did not start."); mExceptionList.Add("Setup did not start.");
return;
} }
Echo("Setup is running. " + DateTime.Now.Subtract(xTimed).ToString(@"ss\.fff")); Echo("Setup is running. " + DateTime.Now.Subtract(xTimed).ToString(@"ss\.fff"));

View file

@ -2,19 +2,21 @@
using System.IO; using System.IO;
using System.Diagnostics; using System.Diagnostics;
using System.Threading; using System.Threading;
using System.Collections.Generic;
namespace Cosmos.Build.Installer { namespace Cosmos.Build.Installer {
public abstract class Task { public abstract class Task {
protected abstract void DoRun(); protected abstract List<string> DoRun();
public void Run() { public void Run() {
try { var exceptions = DoRun();
DoRun();
} catch (Exception ex) {
Log.NewSection("Error"); Log.NewSection("Error");
Log.WriteLine(ex.Message); //Collect all the exceptions from the build stage, and list them
foreach(var msg in exceptions)
{
Log.WriteLine(msg);
}
Log.SetError(); Log.SetError();
}
} }
public bool AmRunning32Bit() { public bool AmRunning32Bit() {