mirror of
https://github.com/danbulant/Cosmos
synced 2026-06-10 10:11:31 +00:00
This commit is contained in:
parent
08131e85c7
commit
25bfaf9934
8 changed files with 177 additions and 41 deletions
23
source/Cosmos.Build.Windows.Config/ChooseVSWindow.xaml
Normal file
23
source/Cosmos.Build.Windows.Config/ChooseVSWindow.xaml
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
<Window
|
||||
x:Class="Cosmos.Build.Windows.Config.ChooseVSWindow"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
Title="ChooseVSWindow"
|
||||
SizeToContent="WidthAndHeight">
|
||||
<StackPanel>
|
||||
<TextBlock
|
||||
TextWrapping="Wrap"
|
||||
Width="272">Multiple Visual Studio installations are detected. in which installation(s) do you want to install the Cosmos Userkit?</TextBlock>
|
||||
<CheckBox
|
||||
HorizontalAlignment="Left"
|
||||
Name="cbxVisualStudio">Visual Studio</CheckBox>
|
||||
<CheckBox
|
||||
HorizontalAlignment="Left"
|
||||
Name="cbxVCSExpress">Visual C# Express</CheckBox>
|
||||
<StackPanel VerticalAlignment="Bottom" Orientation="Horizontal" Margin="4 4 4 4">
|
||||
<Button
|
||||
IsDefault="True"
|
||||
Click="Button_Click">Install</Button>
|
||||
</StackPanel>
|
||||
</StackPanel>
|
||||
</Window>
|
||||
28
source/Cosmos.Build.Windows.Config/ChooseVSWindow.xaml.cs
Normal file
28
source/Cosmos.Build.Windows.Config/ChooseVSWindow.xaml.cs
Normal file
|
|
@ -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 {
|
||||
/// <summary>
|
||||
/// Interaction logic for ChooseVSWindow.xaml
|
||||
/// </summary>
|
||||
public partial class ChooseVSWindow: Window {
|
||||
public ChooseVSWindow() {
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private void Button_Click(object sender, RoutedEventArgs e) {
|
||||
this.DialogResult = true;
|
||||
Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -51,15 +51,28 @@
|
|||
</Reference>
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Xml" />
|
||||
<Reference Include="WindowsBase" />
|
||||
<Reference Include="PresentationCore" />
|
||||
<Reference Include="PresentationFramework" />
|
||||
<Reference Include="UIAutomationProvider">
|
||||
<RequiredTargetFramework>3.0</RequiredTargetFramework>
|
||||
</Reference>
|
||||
<Reference Include="WindowsBase">
|
||||
<RequiredTargetFramework>3.0</RequiredTargetFramework>
|
||||
</Reference>
|
||||
<Reference Include="PresentationCore">
|
||||
<RequiredTargetFramework>3.0</RequiredTargetFramework>
|
||||
</Reference>
|
||||
<Reference Include="PresentationFramework">
|
||||
<RequiredTargetFramework>3.0</RequiredTargetFramework>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ApplicationDefinition Include="App.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
</ApplicationDefinition>
|
||||
<Page Include="ChooseVSWindow.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="MainWindow.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
|
|
@ -74,6 +87,9 @@
|
|||
</Compile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="ChooseVSWindow.xaml.cs">
|
||||
<DependentUpon>ChooseVSWindow.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="MSCorCfg\Fusion.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs">
|
||||
<SubType>Code</SubType>
|
||||
|
|
@ -88,6 +104,7 @@
|
|||
<DependentUpon>Settings.settings</DependentUpon>
|
||||
<DesignTimeSharedInput>True</DesignTimeSharedInput>
|
||||
</Compile>
|
||||
<Compile Include="Tasks\DetectVSTask.cs" />
|
||||
<Compile Include="Tasks\InstallAssembliesTask.cs" />
|
||||
<Compile Include="Tasks\InstallTemplateTask.cs" />
|
||||
<Compile Include="Tasks\ITask.cs" />
|
||||
|
|
|
|||
49
source/Cosmos.Build.Windows.Config/Tasks/DetectVSTask.cs
Normal file
49
source/Cosmos.Build.Windows.Config/Tasks/DetectVSTask.cs
Normal file
|
|
@ -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 + "'");
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -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<string> xTargetPaths = new List<string>();
|
||||
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");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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<string> xTargetPaths = new List<string>();
|
||||
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");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
pause
|
||||
|
|
|
|||
Loading…
Reference in a new issue