diff --git a/source/Cosmos.Build.Windows.Config/ChooseVSWindow.xaml b/source/Cosmos.Build.Windows.Config/ChooseVSWindow.xaml new file mode 100644 index 000000000..d12fc46f5 --- /dev/null +++ b/source/Cosmos.Build.Windows.Config/ChooseVSWindow.xaml @@ -0,0 +1,23 @@ + + + Multiple Visual Studio installations are detected. in which installation(s) do you want to install the Cosmos Userkit? + Visual Studio + Visual C# Express + + + + + diff --git a/source/Cosmos.Build.Windows.Config/ChooseVSWindow.xaml.cs b/source/Cosmos.Build.Windows.Config/ChooseVSWindow.xaml.cs new file mode 100644 index 000000000..2f2214c72 --- /dev/null +++ b/source/Cosmos.Build.Windows.Config/ChooseVSWindow.xaml.cs @@ -0,0 +1,28 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Shapes; + +namespace Cosmos.Build.Windows.Config { + /// + /// Interaction logic for ChooseVSWindow.xaml + /// + public partial class ChooseVSWindow: Window { + public ChooseVSWindow() { + InitializeComponent(); + } + + private void Button_Click(object sender, RoutedEventArgs e) { + this.DialogResult = true; + Close(); + } + } +} diff --git a/source/Cosmos.Build.Windows.Config/Cosmos.Build.Windows.Config.csproj b/source/Cosmos.Build.Windows.Config/Cosmos.Build.Windows.Config.csproj index 31c0aef2a..d032cf04c 100644 --- a/source/Cosmos.Build.Windows.Config/Cosmos.Build.Windows.Config.csproj +++ b/source/Cosmos.Build.Windows.Config/Cosmos.Build.Windows.Config.csproj @@ -51,15 +51,28 @@ - - - + + 3.0 + + + 3.0 + + + 3.0 + + + 3.0 + MSBuild:Compile Designer + + Designer + MSBuild:Compile + MSBuild:Compile Designer @@ -74,6 +87,9 @@ + + ChooseVSWindow.xaml + Code @@ -88,6 +104,7 @@ Settings.settings True + diff --git a/source/Cosmos.Build.Windows.Config/Tasks/DetectVSTask.cs b/source/Cosmos.Build.Windows.Config/Tasks/DetectVSTask.cs new file mode 100644 index 000000000..b586fdeda --- /dev/null +++ b/source/Cosmos.Build.Windows.Config/Tasks/DetectVSTask.cs @@ -0,0 +1,49 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Microsoft.Win32; +using System.Windows; +using System.IO; + +namespace Cosmos.Build.Windows.Config.Tasks { + public class DetectVSTask: Task { + public override string Name { + get { + return "Detecting Visual Studio installation"; + } + } + + public override void Execute() { + var xKey = Registry.LocalMachine.OpenSubKey(@"Software\Microsoft\VisualStudio\9.0", false); + bool xFullVSInstalled = xKey != null; + xKey = Registry.LocalMachine.OpenSubKey(@"Software\Microsoft\VCSExpress\9.0", false); + bool xVCSExpressInstalled = xKey != null; + if (xFullVSInstalled && xVCSExpressInstalled) { + ChooseVSWindow xChoose = new ChooseVSWindow(); + bool? xResult = xChoose.ShowDialog(); + if (!(xResult.HasValue && xResult.Value)) { + throw new Exception("The installation has been canceled"); + } + xFullVSInstalled = xChoose.cbxVisualStudio.IsChecked.HasValue ? xChoose.cbxVisualStudio.IsChecked.Value : false; + xVCSExpressInstalled = xChoose.cbxVCSExpress.IsChecked.HasValue ? xChoose.cbxVCSExpress.IsChecked.Value : false; + } + if(!(xFullVSInstalled || xVCSExpressInstalled)) { + throw new Exception("No Visual Studio Installation found!"); + } + if (xVCSExpressInstalled) { + Tools.VCSPath = (string)xKey.GetValue("InstallDir"); + Tools.VCSTemplatePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), @"Visual Studio 2008\Templates\ProjectTemplates\Visual C#"); + } + if (xFullVSInstalled) { + xKey = Registry.LocalMachine.OpenSubKey(@"Software\Microsoft\VisualStudio\9.0", false); + Tools.VSPath = xKey.GetValue("InstallDir") as string; + xKey = Registry.CurrentUser.OpenSubKey(@"Software\Microsoft\VisualStudio\9.0", false); + Tools.VSTemplatePath = Path.Combine((string)xKey.GetValue("UserProjectTemplatesLocation"), "Visual C#"); + } + System.Windows.MessageBox.Show("VCS path = '" + Tools.VCSPath + "'"); + System.Windows.MessageBox.Show("VS path = '" + Tools.VSPath + "'"); + + } + } +} \ No newline at end of file diff --git a/source/Cosmos.Build.Windows.Config/Tasks/InstallAssembliesTask.cs b/source/Cosmos.Build.Windows.Config/Tasks/InstallAssembliesTask.cs index d810a89b0..a7968b91d 100644 --- a/source/Cosmos.Build.Windows.Config/Tasks/InstallAssembliesTask.cs +++ b/source/Cosmos.Build.Windows.Config/Tasks/InstallAssembliesTask.cs @@ -14,27 +14,27 @@ namespace Cosmos.Build.Windows.Config.Tasks { } public override void Execute() { - string xBaseDir = Tools.Dir("GAC"); - string xTargetDir; - RegistryKey xKey; - OnStatus(0, "Installing Cosmos Assemblies"); - xKey = Registry.LocalMachine.OpenSubKey(@"Software\Microsoft\VisualStudio\9.0", false); - if (xKey == null) - { - // SB: Check for Visual C# Express install - xKey = Registry.LocalMachine.OpenSubKey(@"Software\Microsoft\VCSExpress\9.0", false); - } - xTargetDir = (string)xKey.GetValue("InstallDir"); - xTargetDir = Path.Combine(xTargetDir, "PublicAssemblies"); - string[] xItems = Directory.GetFiles(xBaseDir); - int xCurrent = 1; - foreach (string xFile in Directory.GetFiles(xBaseDir)) { - OnStatus(100 - ((xItems.Length + 1) / xCurrent), "Copying " + Path.GetFileNameWithoutExtension(xFile)); - File.Copy(xFile, Path.Combine(xTargetDir, Path.GetFileName(xFile)), true); - xCurrent++; - OnStatus(100 - (xItems.Length / xCurrent), "Copying " + Path.GetFileNameWithoutExtension(xFile)); + string xBaseDir = Tools.CosmosDir("GAC"); + List xTargetPaths = new List(); + if (!String.IsNullOrEmpty(Tools.VSPath)) { + xTargetPaths.Add(Tools.VSPath); } - xKey = Registry.CurrentUser.OpenSubKey(@"Software\Cosmos", true); + if (!String.IsNullOrEmpty(Tools.VCSPath)) { + xTargetPaths.Add(Tools.VCSPath); + } + OnStatus(0, "Installing Cosmos Assemblies"); + foreach (string xTargetBaseDir in xTargetPaths) { + string xTargetDir = Path.Combine(xTargetBaseDir, "PublicAssemblies"); + string[] xItems = Directory.GetFiles(xBaseDir); + int xCurrent = 1; + foreach (string xFile in Directory.GetFiles(xBaseDir)) { + OnStatus(100 - ((xItems.Length + 1) / xCurrent), "Copying " + Path.GetFileNameWithoutExtension(xFile)); + File.Copy(xFile, Path.Combine(xTargetDir, Path.GetFileName(xFile)), true); + xCurrent++; + OnStatus(100 - (xItems.Length / xCurrent), "Copying " + Path.GetFileNameWithoutExtension(xFile)); + } + } + var xKey = Registry.CurrentUser.OpenSubKey(@"Software\Cosmos", true); if (xKey == null) { xKey = Registry.CurrentUser.CreateSubKey(@"Software\Cosmos"); } diff --git a/source/Cosmos.Build.Windows.Config/Tasks/InstallTemplateTask.cs b/source/Cosmos.Build.Windows.Config/Tasks/InstallTemplateTask.cs index 54bb12510..05f389853 100644 --- a/source/Cosmos.Build.Windows.Config/Tasks/InstallTemplateTask.cs +++ b/source/Cosmos.Build.Windows.Config/Tasks/InstallTemplateTask.cs @@ -15,18 +15,17 @@ namespace Cosmos.Build.Windows.Config.Tasks { public override void Execute() { this.OnStatus(0, "Installing Template"); - string xTemplateFile = Tools.Dir("CosmosBoot.zip"); - string xVSTemplateFolder; - RegistryKey xKey; - xKey = Registry.CurrentUser.OpenSubKey(@"Software\Microsoft\VisualStudio\9.0", false); - if (xKey == null) - { - // SB: Check for Visual C# Express install - xKey = Registry.CurrentUser.OpenSubKey(@"Software\Microsoft\VCSExpress\9.0", false); - } - xVSTemplateFolder = (string)xKey.GetValue("UserProjectTemplatesLocation"); - xVSTemplateFolder = Path.Combine(xVSTemplateFolder, "Visual C#"); - File.Copy(xTemplateFile, Path.Combine(xVSTemplateFolder, "CosmosBoot.zip"), true); + string xTemplateFile = Tools.CosmosDir("CosmosBoot.zip"); + List xTargetPaths = new List(); + if (!String.IsNullOrEmpty(Tools.VSTemplatePath)) { + xTargetPaths.Add(Tools.VSTemplatePath); + } + if (!String.IsNullOrEmpty(Tools.VCSTemplatePath)) { + xTargetPaths.Add(Tools.VCSTemplatePath); + } + foreach (string xTargetFolder in xTargetPaths) { + File.Copy(xTemplateFile, Path.Combine(xTargetFolder, "CosmosBoot.zip"), true); + } this.OnStatus(100, "Installing Template"); } } diff --git a/source/Cosmos.Build.Windows.Config/Tools.cs b/source/Cosmos.Build.Windows.Config/Tools.cs index bffb545c3..28611304c 100644 --- a/source/Cosmos.Build.Windows.Config/Tools.cs +++ b/source/Cosmos.Build.Windows.Config/Tools.cs @@ -8,19 +8,39 @@ namespace Cosmos.Build.Windows.Config { public static class Tools { - public static string Path { get; private set; } + public static string CosmosPath { get; private set; } static Tools() { - Path = System.IO.Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); + CosmosPath = System.IO.Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); } - public static string Dir(params string[] path) + public static string CosmosDir(params string[] path) { - string res = Path; + string res = CosmosPath; foreach (string p in path) res = System.IO.Path.Combine(res, p); return res; } + + public static string VSPath { + get; + set; + } + + public static string VCSPath { + get; + set; + } + + public static string VSTemplatePath { + get; + set; + } + + public static string VCSTemplatePath { + get; + set; + } } } diff --git a/source/PrepareUserKit.bat b/source/PrepareUserKit.bat index e0f7f7202..9ca312c16 100644 --- a/source/PrepareUserKit.bat +++ b/source/PrepareUserKit.bat @@ -15,6 +15,6 @@ rmdir /S /Q "..\Pack" mkdir "..\Pack" mkdir "..\Pack\Cosmos" xcopy /S "..\Build\*.*" "..\Pack\Cosmos" -"..\Tools\7zip\7z.exe" a -tzip Cosmos.zip "..\Pack\*.*" -r +"..\Tools\7zip\7z.exe" a -tzip CosmosUserkit.zip "..\Pack\*.*" -r rmdir /S /Q "..\Pack" -pause \ No newline at end of file +pause