This commit is contained in:
mterwoord_cp 2008-01-22 06:58:30 +00:00
parent 64e0ee3813
commit 71cb2f0136

View file

@ -16,9 +16,14 @@ namespace Cosmos.Build.Windows.Config.Tasks {
public override void Execute() { public override void Execute() {
var xKey = Registry.LocalMachine.OpenSubKey(@"Software\Microsoft\VisualStudio\9.0", false); var xKey = Registry.LocalMachine.OpenSubKey(@"Software\Microsoft\VisualStudio\9.0", false);
bool xFullVSInstalled = xKey != null; var xVSPath = xKey.GetValue("InstallDir") as string;
xKey = Registry.CurrentUser.OpenSubKey(@"Software\Microsoft\VisualStudio\9.0", false);
var xVSTemplatePath = String.IsNullOrEmpty(xKey.GetValue("UserProjectTemplatesLocation") as string) ? String.Empty : Path.Combine((string)xKey.GetValue("UserProjectTemplatesLocation"), "Visual C#");
bool xFullVSInstalled = !(String.IsNullOrEmpty(xVSPath) && string.IsNullOrEmpty(xVSTemplatePath));
xKey = Registry.LocalMachine.OpenSubKey(@"Software\Microsoft\VCSExpress\9.0", false); xKey = Registry.LocalMachine.OpenSubKey(@"Software\Microsoft\VCSExpress\9.0", false);
bool xVCSExpressInstalled = xKey != null; var xVCSPath = (string)xKey.GetValue("InstallDir");
var xVCSTemplatePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), @"Visual Studio 2008\Templates\ProjectTemplates\Visual C#");
bool xVCSExpressInstalled = !(String.IsNullOrEmpty(xVCSPath) && string.IsNullOrEmpty(xVCSTemplatePath));
if (xFullVSInstalled && xVCSExpressInstalled) { if (xFullVSInstalled && xVCSExpressInstalled) {
ChooseVSWindow xChoose = new ChooseVSWindow(); ChooseVSWindow xChoose = new ChooseVSWindow();
bool? xResult = xChoose.ShowDialog(); bool? xResult = xChoose.ShowDialog();
@ -28,21 +33,17 @@ namespace Cosmos.Build.Windows.Config.Tasks {
xFullVSInstalled = xChoose.cbxVisualStudio.IsChecked.HasValue ? xChoose.cbxVisualStudio.IsChecked.Value : false; xFullVSInstalled = xChoose.cbxVisualStudio.IsChecked.HasValue ? xChoose.cbxVisualStudio.IsChecked.Value : false;
xVCSExpressInstalled = xChoose.cbxVCSExpress.IsChecked.HasValue ? xChoose.cbxVCSExpress.IsChecked.Value : false; xVCSExpressInstalled = xChoose.cbxVCSExpress.IsChecked.HasValue ? xChoose.cbxVCSExpress.IsChecked.Value : false;
} }
if(!(xFullVSInstalled || xVCSExpressInstalled)) { if (!(xFullVSInstalled || xVCSExpressInstalled)) {
throw new Exception("No Visual Studio Installation found!"); throw new Exception("No Visual Studio Installation found!");
} }
if (xVCSExpressInstalled) { if (xVCSExpressInstalled) {
Tools.VCSPath = (string)xKey.GetValue("InstallDir"); Tools.VCSPath = xVCSPath;
Tools.VCSTemplatePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), @"Visual Studio 2008\Templates\ProjectTemplates\Visual C#"); Tools.VCSTemplatePath = xVCSTemplatePath;
} }
if (xFullVSInstalled) { if (xFullVSInstalled) {
xKey = Registry.LocalMachine.OpenSubKey(@"Software\Microsoft\VisualStudio\9.0", false); Tools.VSPath = xVSPath;
Tools.VSPath = xKey.GetValue("InstallDir") as string; Tools.VSTemplatePath = xVSTemplatePath;
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 + "'");
} }
} }