public void RunStarted(object automationObject, Dictionary <string, string> replacementsDictionary, WizardRunKind runKind, object[] customParams) { _dte = (DTE)automationObject; /* The solution directory will be this directories parent * when the Type attribute of the VSTemplate element is ProjectGroup */ _solutionDir = System.IO.Path.GetDirectoryName(replacementsDictionary["$destinationdirectory$"]); // customParams[0] is a default custom param that contains the physical location of the template that is currently being applied _templateDir = System.IO.Path.GetDirectoryName(customParams[0] as string); // Display a form to the user. The form collects // input for the custom message. dlg = new WizardDialog(); beforeOpenDialog(); var res = dlg.ShowDialog(); if (res == DialogResult.Cancel) { throw new WizardBackoutException(); } if (res != DialogResult.OK) { throw new WizardCancelledException(); } bool mainInCpp = dlg.mainInCpp.Checked && dlg.prjTypeConsole.Checked; // for vcxproj if (dlg.prjTypeWindows.Checked) { replacementsDictionary.Add("$subsystem$", "Windows"); // for vcxproj replacementsDictionary.Add("$subsys$", "2"); // for visualdproj } else { replacementsDictionary.Add("$subsystem$", "Console"); replacementsDictionary.Add("$subsys$", "1"); } if (dlg.prjTypeDLL.Checked) { replacementsDictionary.Add("$apptype$", "DynamicLibrary"); // for main.d replacementsDictionary.Add("$configtype$", "DynamicLibrary"); // for vcxproj replacementsDictionary.Add("$outputtype$", "2"); // for visualdproj replacementsDictionary.Add("$outputext$", "dll"); } else if (dlg.prjTypeLib.Checked) { replacementsDictionary.Add("$apptype$", "StaticLibrary"); replacementsDictionary.Add("$configtype$", "StaticLibrary"); replacementsDictionary.Add("$outputtype$", "1"); replacementsDictionary.Add("$outputext$", "lib"); } else { string app = dlg.prjTypeWindows.Checked ? "WindowsApp" : mainInCpp ? "ConsoleAppMainInCpp" : "ConsoleApp"; replacementsDictionary.Add("$apptype$", app); replacementsDictionary.Add("$configtype$", "Application"); replacementsDictionary.Add("$outputtype$", "0"); replacementsDictionary.Add("$outputext$", "exe"); } replacementsDictionary.Add("$mainInCpp$", mainInCpp ? "1" : "0"); replacementsDictionary.Add("$addStdafxH$", dlg.precompiledHeaders.Checked || mainInCpp ? "1" : "0"); replacementsDictionary.Add("$addStdafxCpp$", dlg.precompiledHeaders.Checked ? "1" : "0"); replacementsDictionary.Add("$PrecompiledHeader$", dlg.precompiledHeaders.Checked ? "Use" : "NotUsing"); replacementsDictionary.Add("$x86mscoff$", dlg.platformx86OMF.Checked ? "0" : "1"); int numCompiler = 0; if (dlg.compilerDMD.Checked) { numCompiler++; } if (dlg.compilerLDC.Checked) { numCompiler++; } if (dlg.compilerGDC.Checked) { numCompiler++; } if (numCompiler <= 1) { int compiler = dlg.compilerLDC.Checked ? 2 : dlg.compilerGDC.Checked ? 1 : 0; AddConfigReplacements(replacementsDictionary, 1, compiler, ""); } else { numCompiler = 0; if (dlg.compilerDMD.Checked) { AddConfigReplacements(replacementsDictionary, ++numCompiler, 0, " DMD"); } if (dlg.compilerLDC.Checked) { AddConfigReplacements(replacementsDictionary, ++numCompiler, 2, " LDC"); } if (dlg.compilerGDC.Checked) { AddConfigReplacements(replacementsDictionary, ++numCompiler, 1, " GDC"); } } while (numCompiler++ <= 3) { string idxs = numCompiler.ToString(); replacementsDictionary.Add("$platformx86_" + idxs + "$", "0"); replacementsDictionary.Add("$platformx64_" + idxs + "$", "0"); } }
public void RunStarted(object automationObject, Dictionary <string, string> replacementsDictionary, WizardRunKind runKind, object[] customParams) { _dte = (DTE)automationObject; // Display a form to the user. The form collects // input for the custom message. dlg = new WizardDialog(); beforeOpenDialog(); var res = dlg.ShowDialog(); if (res == DialogResult.Cancel) { throw new WizardBackoutException(); } if (res != DialogResult.OK) { throw new WizardCancelledException(); } // for vcxproj if (dlg.prjTypeWindows.Checked) { replacementsDictionary.Add("$subsystem$", "Windows"); // for vcxproj replacementsDictionary.Add("$subsys$", "2"); // for visualdproj } else { replacementsDictionary.Add("$subsystem$", "Console"); replacementsDictionary.Add("$subsys$", "1"); } if (dlg.prjTypeDLL.Checked) { replacementsDictionary.Add("$apptype$", "DynamicLibrary"); // for main.d replacementsDictionary.Add("$configtype$", "DynamicLibrary"); // for vcxproj replacementsDictionary.Add("$outputtype$", "2"); // for visualdproj replacementsDictionary.Add("$outputext$", "dll"); } else if (dlg.prjTypeLib.Checked) { replacementsDictionary.Add("$apptype$", "StaticLibrary"); replacementsDictionary.Add("$configtype$", "StaticLibrary"); replacementsDictionary.Add("$outputtype$", "1"); replacementsDictionary.Add("$outputext$", "lib"); } else { replacementsDictionary.Add("$apptype$", dlg.prjTypeWindows.Checked ? "WindowsApp" : "ConsoleApp"); replacementsDictionary.Add("$configtype$", "Application"); replacementsDictionary.Add("$outputtype$", "0"); replacementsDictionary.Add("$outputext$", "exe"); } replacementsDictionary.Add("$x86mscoff$", dlg.platformx86OMF.Checked ? "0" : "1"); int numCompiler = 0; if (dlg.compilerDMD.Checked) { numCompiler++; } if (dlg.compilerLDC.Checked) { numCompiler++; } if (dlg.compilerGDC.Checked) { numCompiler++; } if (numCompiler <= 1) { int compiler = dlg.compilerLDC.Checked ? 2 : dlg.compilerGDC.Checked ? 1 : 0; AddConfigReplacements(replacementsDictionary, 1, compiler, ""); } else { numCompiler = 0; if (dlg.compilerDMD.Checked) { AddConfigReplacements(replacementsDictionary, ++numCompiler, 0, " DMD"); } if (dlg.compilerLDC.Checked) { AddConfigReplacements(replacementsDictionary, ++numCompiler, 0, " LDC"); } if (dlg.compilerGDC.Checked) { AddConfigReplacements(replacementsDictionary, ++numCompiler, 0, " GDC"); } } while (numCompiler++ <= 3) { string idxs = numCompiler.ToString(); replacementsDictionary.Add("$platformx86_" + idxs + "$", "0"); replacementsDictionary.Add("$platformx64_" + idxs + "$", "0"); } }