Skip to content

Commit

Permalink
Add the ability to run builder for VS2015 and VS2013
Browse files Browse the repository at this point in the history
  • Loading branch information
kant2002 committed May 8, 2015
1 parent e8de8ad commit 62de380
Show file tree
Hide file tree
Showing 5 changed files with 139 additions and 33 deletions.
13 changes: 8 additions & 5 deletions source/Cosmos.Build.Builder/App.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Linq;
using System.Windows;
using Cosmos.Build.Installer;

namespace Cosmos.Build.Builder {
public partial class App : Application {
Expand All @@ -17,6 +14,7 @@ public partial class App : Application {
public static bool IgnoreVS;
public static bool TestMode = false;
public static bool HasParams = false;
public static VsVersion VsVersion;

protected override void OnStartup(StartupEventArgs e) {
HasParams = e.Args.Length > 0;
Expand All @@ -35,6 +33,11 @@ protected override void OnStartup(StartupEventArgs e) {
// For use during dev of Builder only.
IgnoreVS = xArgs.Contains("-IGNOREVS");
TestMode = xArgs.Contains("-TESTMODE");
if (xArgs.Contains("-VS2015") || xArgs.Contains("/VS2015")) {
VsVersion = VsVersion.Vs2015;
Paths.VsVersion = VsVersion.Vs2015;
}

base.OnStartup(e);
}
}
Expand Down
38 changes: 34 additions & 4 deletions source/Cosmos.Build.Builder/CosmosTask.cs
Original file line number Diff line number Diff line change
Expand Up @@ -233,13 +233,21 @@ protected void CheckPrereqs() {
CheckIfUserKitRunning();
CheckIsVsRunning();
CheckIfBuilderRunning();

CheckVs2013();

switch (App.VsVersion) {
case VsVersion.Vs2013:
CheckVs2013();
CheckForInstall("Microsoft Visual Studio 2013 SDK", true);
break;
case VsVersion.Vs2015:
CheckVs2015();
CheckForInstall("Microsoft Visual Studio 2015 RC SDK", true);
break;
}

//works also without, only close of VMWare is not working! CheckNet35Sp1(); // Required by VMWareLib
CheckNet403();
CheckForInno();
CheckForInstall("Microsoft Visual Studio 2013 SDK", true);
bool vmWareInstalled = true;
bool bochsInstalled = IsBochsInstalled();
if (!CheckForInstall("VMware Workstation", false)) {
Expand Down Expand Up @@ -322,6 +330,19 @@ void CheckVs2013() {
}
}

void CheckVs2015() {
Echo("Checking for Visual Studio 2015 RC");
string key = @"SOFTWARE\Microsoft\VisualStudio\14.0";
if (Environment.Is64BitOperatingSystem)
key = @"SOFTWARE\Wow6432Node\Microsoft\VisualStudio\14.0";
using (var xKey = Registry.LocalMachine.OpenSubKey(key)) {
string xDir = (string)xKey.GetValue("InstallDir");
if (String.IsNullOrWhiteSpace(xDir)) {
throw new Exception("Visual Studio 2015 RC not detected!");
}
}
}

void WriteDevKit() {
Section("Writing Dev Kit to Registry");

Expand Down Expand Up @@ -407,7 +428,16 @@ void CreateSetup() {
throw new Exception("Cannot find Inno setup.");
}
string xCfg = App.IsUserKit ? "UserKit" : "DevKit";
StartConsole(xISCC, @"/Q " + Quoted(mInnoFile) + " /dBuildConfiguration=" + xCfg);
string vsVersionConfiguration = "vs2013";
switch (App.VsVersion) {
case VsVersion.Vs2013:
vsVersionConfiguration = "vs2013";
break;
case VsVersion.Vs2015:
vsVersionConfiguration = "vs2015";
break;
}
StartConsole(xISCC, @"/Q " + Quoted(mInnoFile) + " /dBuildConfiguration=" + xCfg + " /dVsVersion=" + vsVersionConfiguration);

if (App.IsUserKit) {
File.Delete(mInnoFile);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
<Compile Include="Paths.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Task.cs" />
<Compile Include="VsVersion.cs" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Expand Down
102 changes: 78 additions & 24 deletions source/Cosmos.Build.Installer/Paths.cs
Original file line number Diff line number Diff line change
@@ -1,27 +1,81 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using Microsoft.Win32;
namespace Cosmos.Build.Installer {
public static class Paths {
static Paths() {
if (Global.IsX64) {
ProgFiles32 = Environment.GetFolderPath(Environment.SpecialFolder.ProgramFilesX86);
ProgFiles64 = Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles);
} else {
ProgFiles32 = Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles);
}
// The Install Dir will pickup only the Visual Studio 2013 path currently.
RegistryKey key = Registry.LocalMachine.OpenSubKey(string.Format(@"SOFTWARE{0}\microsoft\VisualStudio\12.0",
Environment.Is64BitOperatingSystem ? @"\Wow6432Node" : ""));
VSInstall = key.GetValue("InstallDir") as string;
Windows = Environment.GetFolderPath(Environment.SpecialFolder.Windows);

namespace Cosmos.Build.Installer
{
public static class Paths
{
/// <summary>
/// Version of Visual Studio for which paths should be detected.
/// </summary>
private static VsVersion vsVersion;

public static readonly string ProgFiles32;
public static readonly string ProgFiles64;
public static readonly string Windows;

static Paths()
{
if (Global.IsX64)
{
ProgFiles32 = Environment.GetFolderPath(Environment.SpecialFolder.ProgramFilesX86);
ProgFiles64 = Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles);
}
else
{
ProgFiles32 = Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles);
}

UpdateVsPath();
Windows = Environment.GetFolderPath(Environment.SpecialFolder.Windows);
}

/// <summary>
/// Gets path where Visual Studio installed
/// </summary>
public static string VSInstall { get; private set; }

/// <summary>
/// Version of Visual Studio for which paths should be detected.
/// </summary>
public static VsVersion VsVersion
{
get { return vsVersion; }

set
{
vsVersion = value;
UpdateVsPath();
}
}

/// <summary>
/// Updates path to VS version
/// </summary>
private static void UpdateVsPath()
{
// The Install Dir will pickup only the Visual Studio 2013/2015 path currently.
RegistryKey key;
string vsVersionCode;
switch (VsVersion)
{
case VsVersion.Vs2013:
vsVersionCode = "12.0";
break;
case VsVersion.Vs2015:
vsVersionCode = "14.0";
break;
default:
throw new NotSupportedException("Versions of VS other then 2013 and 2015 not supported.");
}

var registryKey = string.Format(
@"SOFTWARE{0}\microsoft\VisualStudio\{1}",
Environment.Is64BitOperatingSystem ? @"\Wow6432Node" : "",
vsVersionCode);
key = Registry.LocalMachine.OpenSubKey(registryKey);
VSInstall = key.GetValue("InstallDir") as string;
}

}
public static readonly string ProgFiles32;
public static readonly string ProgFiles64;
public static readonly string VSInstall;
public static readonly string Windows;
}
}
}
18 changes: 18 additions & 0 deletions source/Cosmos.Build.Installer/VsVersion.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
namespace Cosmos.Build.Installer
{
/// <summary>
/// Version of Visual Studio
/// </summary>
public enum VsVersion
{
/// <summary>
/// Visual Studio VS 2013
/// </summary>
Vs2013,

/// <summary>
/// Visual Studio VS 2015
/// </summary>
Vs2015
}
}

0 comments on commit 62de380

Please sign in to comment.