public void RunStarted(object automationObject, Dictionary <string, string> replacementsDictionary, WizardRunKind runKind, object[] customParams) { if (wizard != null) { wizard.RunStarted(automationObject, replacementsDictionary, runKind, customParams); } }
public void RunStarted(object automationObject, Dictionary <string, string> replacementsDictionary, WizardRunKind runKind, object[] customParams) { var shouldProcessProject = true; if (_wizardForm is HiddenForm <TProjectOptions> ) { shouldProcessProject = true; } else { var result = _wizardForm.ShowDialog(); shouldProcessProject = result == DialogResult.OK; } if (shouldProcessProject) { _projectOptions = _wizardForm.ProjectOptions; // update replacement mapppings _projectSetupService.MapProjectProperties(replacementsDictionary, _projectOptions); // re-generate nuget packages if (_projectSetupService.UpdateVSProjectNuGetPackages(_projectOptions, customParams[0].ToString())) { // run nuget stuff var asm = Assembly.Load("NuGet.VisualStudio.Interop, Version=1.0.0.0, Culture=Neutral, PublicKeyToken=b03f5f7f11d50a3a"); _nuGetWizard = (IWizard)asm.CreateInstance("NuGet.VisualStudio.TemplateWizard"); _nuGetWizard.RunStarted(automationObject, replacementsDictionary, runKind, customParams); } } }
public void RunStarted(object automationObject, Dictionary <string, string> replacementsDictionary, WizardRunKind runKind, object[] customParams) { var provider = WizardHelpers.GetProvider(automationObject); if (_wizard == null) { try { Directory.Delete(replacementsDictionary["$destinationdirectory$"]); Directory.Delete(replacementsDictionary["$solutiondirectory$"]); } catch { // If it fails (doesn't exist/contains files/read-only), let the directory stay. } var uiShell = ServiceProvider.GlobalProvider.GetService(typeof(SVsUIShell)) as IVsUIShell; Debug.Assert(uiShell != null, "uiShell was null."); uiShell.ShowMessageBox(0, Guid.Empty, SR.ProductName, ProjectWizardResources.AzureToolsRequired, null, 0, OLEMSGBUTTON.OLEMSGBUTTON_OK, OLEMSGDEFBUTTON.OLEMSGDEFBUTTON_FIRST, OLEMSGICON.OLEMSGICON_CRITICAL, 1, out var result); // User cancelled, so go back to the New Project dialog throw new WizardBackoutException(); } // Run the original wizard to get the right replacements _wizard.RunStarted(automationObject, replacementsDictionary, runKind, customParams); }
public void RunStarted(object automationObject, Dictionary <string, string> props, WizardRunKind runKind, object[] customParams) { this.dte = automationObject as EnvDTE._DTE; // Check that SharpDX is correctly installed if (string.IsNullOrEmpty(Environment.GetEnvironmentVariable("SharpDXSdkDir"))) { MessageBox.Show("Unable to find SharpDX installation directory. Expecting [SharpDXSdkDir] environment variable", "SharpDX Toolkit Wizard Error", MessageBoxButtons.OK, MessageBoxIcon.Error); throw new WizardCancelledException("Expecting [SharpDXSdkDir] environment variable"); } props.Add("$safeclassname$", props["$safeprojectname$"].Replace(".", string.Empty)); props["$currentVsCulture$"] = System.Threading.Thread.CurrentThread.CurrentUICulture.Name; //Call win form created in the project to accept user input wizardForm = new WizardForm(props); var result = wizardForm.ShowDialog(); if (result == DialogResult.Cancel) { throw new WizardCancelledException(); } // Hack on WinRT / WinRT XAML to run the certificate wizards as well as our own wizard if (GetKey(props, "$sharpdx_platform_winrt$") || GetKey(props, "$sharpdx_platform_winrt_xaml$")) { try { var assembly = Assembly.Load("Microsoft.VisualStudio.WinRT.TemplateWizards, Version=11.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"); var type = assembly.GetType("Microsoft.VisualStudio.WinRT.TemplateWizards.CreateProjectCertificate.Wizard"); winRTCertificateWizard = (IWizard)Activator.CreateInstance(type); } catch (Exception ex) { } } if (winRTCertificateWizard != null) { winRTCertificateWizard.RunStarted(automationObject, props, runKind, customParams); } // Set spritebatch feature if spritetexture or spritefont is true if (GetKey(props, "$sharpdx_feature_spritetexture$") || GetKey(props, "$sharpdx_feature_spritefont$")) { props["$sharpdx_feature_spritebatch$"] = "true"; } if (GetKey(props, "$sharpdx_feature_model3d$") || GetKey(props, "$sharpdx_feature_primitive3d$")) { props["$sharpdx_feature_3d$"] = "true"; } if (GetKey(props, "$sharpdx_platform_winrt_xaml$")) { props["$sharpdx_platform_winrt$"] = "true"; } isPlatformWP8 = props.ContainsKey("$sharpdx_platform_wp8$"); }
public void RunStarted(object automationObject, Dictionary <string, string> replacementsDictionary, WizardRunKind runKind, object[] customParams) { var provider = WizardHelpers.GetProvider(automationObject); try { if (AreToolsInstalled(provider)) { // If we fail to find the wizard, we will redirect the user to // install the required packages. var asm = Assembly.Load("Microsoft.VisualStudio.CloudService.Wizard,Version=1.0.0.0,Culture=neutral,PublicKeyToken=b03f5f7f11d50a3a"); var type = asm.GetType("Microsoft.VisualStudio.CloudService.Wizard.CloudServiceWizard"); _wizard = type.InvokeMember(null, BindingFlags.CreateInstance, null, null, new object[0], CultureInfo.CurrentCulture) as IWizard; } } catch (ArgumentException) { } catch (BadImageFormatException) { } catch (IOException) { } catch (MemberAccessException) { } if (_wizard == null) { try { Directory.Delete(replacementsDictionary["$destinationdirectory$"]); Directory.Delete(replacementsDictionary["$solutiondirectory$"]); } catch { // If it fails (doesn't exist/contains files/read-only), let the directory stay. } var dlg = new TaskDialog(provider) { Title = Strings.ProductTitle, MainInstruction = Strings.AzureToolsRequired, Content = Strings.AzureToolsInstallInstructions, AllowCancellation = true }; dlg.Buttons.Add(TaskDialogButton.Cancel); var download = new TaskDialogButton(Strings.DownloadAndInstall); dlg.Buttons.Insert(0, download); if (dlg.ShowModal() == download) { InstallTools(provider); throw new WizardCancelledException(); } // User cancelled, so go back to the New Project dialog throw new WizardBackoutException(); } // Run the original wizard to get the right replacements _wizard.RunStarted(automationObject, replacementsDictionary, runKind, customParams); }
public void RunStarted(object automationObject, Dictionary <string, string> props, WizardRunKind runKind, object[] customParams) { this.dte = automationObject as EnvDTE._DTE; props.Add("$safeclassname$", props["$safeprojectname$"].Replace(".", string.Empty)); props["$currentVsCulture$"] = System.Threading.Thread.CurrentThread.CurrentUICulture.Name; //Call win form created in the project to accept user input wizardForm = new WizardForm(props); var result = wizardForm.ShowDialog(); if (result == DialogResult.Cancel) { throw new WizardCancelledException(); } // Hack on WinRT / WinRT XAML to run the certificate wizards as well as our own wizard if (GetKey(props, "$sharpdx_platform_winrt$") || GetKey(props, "$sharpdx_platform_winrt_xaml$")) { try { var assembly = Assembly.Load("Microsoft.VisualStudio.WinRT.TemplateWizards, Version=11.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"); var type = assembly.GetType("Microsoft.VisualStudio.WinRT.TemplateWizards.CreateProjectCertificate.Wizard"); winRTCertificateWizard = (IWizard)Activator.CreateInstance(type); } catch (Exception ex) { } } if (winRTCertificateWizard != null) { winRTCertificateWizard.RunStarted(automationObject, props, runKind, customParams); } // Set spritebatch feature if spritetexture or spritefont is true if (GetKey(props, "$sharpdx_feature_spritetexture$") || GetKey(props, "$sharpdx_feature_spritefont$")) { props["$sharpdx_feature_spritebatch$"] = "true"; } if (GetKey(props, "$sharpdx_feature_model3d$") || GetKey(props, "$sharpdx_feature_primitive3d$")) { props["$sharpdx_feature_3d$"] = "true"; } if (GetKey(props, "$sharpdx_platform_winrt_xaml$")) { props["$sharpdx_platform_winrt$"] = "true"; } }
public void RunStarted(object automationObject, Dictionary <string, string> replacementsDictionary, WizardRunKind runKind, object[] customParams) { NuGetWizard.RunStarted(automationObject, replacementsDictionary, runKind, customParams); dte = (DTE2)automationObject; var solutionName = Path.GetFileNameWithoutExtension(dte.Solution.FullName); var safesolutionName = UnsafeCharRegex.Replace(solutionName.Replace(" ", "_"), string.Empty); var form = new SilverlightLibWizard(safesolutionName); var dialogResult = form.ShowDialog(); if (dialogResult != DialogResult.OK) { throw new Microsoft.VisualStudio.TemplateWizard.WizardCancelledException(); } var solutionBaseNamespace = form.SolutionBaseNamespace; replacementsDictionary.Add("$solutionbasenamespace$", solutionBaseNamespace); }
public void RunStarted(object automationObject, Dictionary <string, string> replacementsDictionary, WizardRunKind runKind, object[] customParams) { if (runKind == WizardRunKind.AsNewItem || runKind == WizardRunKind.AsNewProject) { NuGetWizard.RunStarted(automationObject, replacementsDictionary, runKind, customParams); } // run for multi project if (runKind == WizardRunKind.AsMultiProject) { dte = (DTE2)automationObject; // read project name solutionname = replacementsDictionary["$projectname$"]; safesolutionname = replacementsDictionary["$safeprojectname$"].Replace(" ", "_"); } // save project name as solution name replacementsDictionary.Add("$solutionname$", solutionname); replacementsDictionary.Add("$safesolutionname$", safesolutionname); }
public void RunStarted(object automationObject, Dictionary <string, string> replacementsDictionary, WizardRunKind runKind, object[] customParams) { var provider = WizardHelpers.GetProvider(automationObject); if (_wizard == null) { try { Directory.Delete(replacementsDictionary["$destinationdirectory$"]); Directory.Delete(replacementsDictionary["$solutiondirectory$"]); } catch { // If it fails (doesn't exist/contains files/read-only), let the directory stay. } var dlg = new TaskDialog(provider) { Title = Strings.ProductTitle, MainInstruction = Strings.AzureToolsRequired, Content = Strings.AzureToolsInstallInstructions, AllowCancellation = true }; dlg.Buttons.Add(TaskDialogButton.Cancel); var download = new TaskDialogButton(Strings.DownloadAndInstall); dlg.Buttons.Insert(0, download); if (dlg.ShowModal() == download) { StartDownload(provider); throw new WizardCancelledException(); } // User cancelled, so go back to the New Project dialog throw new WizardBackoutException(); } OfferUpgrade(provider); // Run the original wizard to get the right replacements _wizard.RunStarted(automationObject, replacementsDictionary, runKind, customParams); }
public void RunStarted(object automationObject, Dictionary <string, string> replacementsDictionary, WizardRunKind runKind, object[] customParams) { var provider = WizardHelpers.GetProvider(automationObject); if (_wizard == null) { try { Directory.Delete(replacementsDictionary["$destinationdirectory$"]); Directory.Delete(replacementsDictionary["$solutiondirectory$"]); } catch { // If it fails (doesn't exist/contains files/read-only), let the directory stay. } var dlg = new TaskDialog(provider) { Title = Resources.PythonToolsForVisualStudio, MainInstruction = Resources.AzureToolsRequired, Content = Resources.AzureToolsInstallInstructions, AllowCancellation = true }; var download = new TaskDialogButton(Resources.DownloadAndInstall); dlg.Buttons.Add(download); dlg.Buttons.Add(TaskDialogButton.Cancel); if (dlg.ShowModal() == download) { Process.Start(new ProcessStartInfo(AzureToolsDownload)); throw new WizardCancelledException(); } // User cancelled, so go back to the New Project dialog throw new WizardBackoutException(); } if (_recommendUpgrade) { var sm = SettingsManagerCreator.GetSettingsManager(provider); var store = sm.GetReadOnlySettingsStore(SettingsScope.UserSettings); if (!store.CollectionExists(PythonConstants.DontShowUpgradeDialogAgainCollection) || !store.GetBoolean(PythonConstants.DontShowUpgradeDialogAgainCollection, DontShowUpgradeDialogAgainProperty, false)) { var dlg = new TaskDialog(provider) { Title = Resources.PythonToolsForVisualStudio, MainInstruction = Resources.AzureToolsUpgradeRecommended, Content = Resources.AzureToolsUpgradeInstructions, AllowCancellation = true, VerificationText = Resources.DontShowAgain }; var download = new TaskDialogButton(Resources.DownloadAndInstall); dlg.Buttons.Add(download); var cont = new TaskDialogButton(Resources.ContinueWithoutAzureToolsUpgrade); dlg.Buttons.Add(cont); dlg.Buttons.Add(TaskDialogButton.Cancel); var response = dlg.ShowModal(); if (response != cont) { try { Directory.Delete(replacementsDictionary["$destinationdirectory$"]); Directory.Delete(replacementsDictionary["$solutiondirectory$"]); } catch { // If it fails (doesn't exist/contains files/read-only), let the directory stay. } } if (dlg.SelectedVerified) { var rwStore = sm.GetWritableSettingsStore(SettingsScope.UserSettings); rwStore.CreateCollection(PythonConstants.DontShowUpgradeDialogAgainCollection); rwStore.SetBoolean(PythonConstants.DontShowUpgradeDialogAgainCollection, DontShowUpgradeDialogAgainProperty, true); } if (response == download) { Process.Start(new ProcessStartInfo(AzureToolsDownload)); throw new WizardCancelledException(); } else if (response == TaskDialogButton.Cancel) { // User cancelled, so go back to the New Project dialog throw new WizardBackoutException(); } } } // Run the original wizard to get the right replacements _wizard.RunStarted(automationObject, replacementsDictionary, runKind, customParams); }
public void RunStarted(object automationObject, Dictionary <string, string> replacementsDictionary, WizardRunKind runKind, object[] customParams) { var shouldProcessProject = true; if (_wizardForm is HiddenForm <TProjectOptions> ) { shouldProcessProject = true; } else { var result = _wizardForm.ShowDialog(); shouldProcessProject = result == DialogResult.OK; } if (shouldProcessProject) { _projectOptions = _wizardForm.ProjectOptions; try { // update replacement mapppings _projectSetupService.MapProjectProperties(replacementsDictionary, _projectOptions); } catch (Exception ee) { MessageBox.Show(string.Format("MapProjectProperties:" + ee)); } var res = false; try { res = _projectSetupService.UpdateVSProjectNuGetPackages(_projectOptions, customParams[0].ToString()); } catch (Exception ee) { MessageBox.Show(string.Format("UpdateVSProjectNuGetPackages:" + ee)); } // re-generate nuget packages if (res) { try { // run nuget stuff var asm = Assembly.Load("NuGet.VisualStudio.Interop, Version=1.0.0.0, Culture=Neutral, PublicKeyToken=b03f5f7f11d50a3a"); // replacing project file as VS2015 lock original one preventing it from the updates // VSProjectSetupServiceBase class updates the project file with correct NuGet packages // Investigate Visual Studio 2015 Community / Premium support #23 // https://github.com/SubPointSolutions/spmeta2-vsixextensions/issues/23 var tmpCustomParams = customParams.ToArray(); tmpCustomParams[0] = _projectSetupService.UpdateVSProjectNuGetPackagesFilePath; _nuGetWizard = (IWizard)asm.CreateInstance("NuGet.VisualStudio.TemplateWizard"); _nuGetWizard.RunStarted(automationObject, replacementsDictionary, runKind, tmpCustomParams); } catch (Exception ee) { MessageBox.Show(string.Format("RunStarted:" + ee)); } } } }
public void RunStarted(object automationObject, Dictionary <string, string> replacementsDictionary, WizardRunKind runKind, object[] customParams) { DTE dte = (DTE)Microsoft.VisualStudio.Shell.Package.GetGlobalService(typeof(SDTE)); Projects dteProjects = dte.Solution.Projects; List <string> projectNames = new List <string>(); bool isPlatformSet = false; foreach (Project project in dteProjects) { // TODO: Filter out projects not applicable projects.Add(project); projectNames.Add(project.Name); } ConfigurationData configurationData = new ConfigurationData(dte, projectNames.ToArray()); SinglePageWizardDialog wiz = new SinglePageWizardDialog(Resources.WizardTitle, configurationData); bool?success = false; // If RunSilent is true, we're in automated testing if (replacementsDictionary[RunSilent] == "True") { success = true; SetDefaultData(ref configurationData); } else { success = wiz.ShowModal(); } if (success == false) { throw new WizardCancelledException(); } selectedProjectIndex = configurationData.ProjectIndex; if (selectedProjectIndex >= 0) { foreach (Property prop in projects[selectedProjectIndex].Properties) { if (prop.Name.Equals("WindowsTargetPlatformVersion")) { replacementsDictionary[TargetPlatformVersion] = (string)prop.Value; isPlatformSet = true; } } } string consumeGTestAs = configurationData.IsGTestStatic ? "static" : "dyn"; string runtimeLibs = configurationData.IsRuntimeStatic ? "static" : "dyn"; string nugetPackage = "Microsoft.googletest.v140.windesktop.msvcstl." + consumeGTestAs + ".rt-" + runtimeLibs; // Work around so we can choose the package for the nuget wizard string tmpWizardData = Path.GetTempFileName(); File.AppendAllText(tmpWizardData, "<VSTemplate Version=\"3.0.0\" xmlns=\"http://schemas.microsoft.com/developer/vstemplate/2005\" Type=\"Project\"><WizardData>"); File.AppendAllText(tmpWizardData, replacementsDictionary[WizardData].Replace("$nugetpackage$", nugetPackage)); File.AppendAllText(tmpWizardData, "</WizardData></VSTemplate>"); customParams[0] = tmpWizardData; try { Assembly nugetAssembly = Assembly.Load("NuGet.VisualStudio.Interop, Version=1.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"); nugetWizard = (IWizard)nugetAssembly.CreateInstance("NuGet.VisualStudio.TemplateWizard"); nugetWizard.RunStarted(automationObject, replacementsDictionary, runKind, customParams); } catch (Exception) { ShowRtlAwareMessageBox(Resources.NuGetInteropNotFound); throw; } if (configurationData.IsRuntimeStatic) { replacementsDictionary[RuntimeRelease] = "MultiThreaded"; replacementsDictionary[RuntimeDebug] = "MultiThreadedDebug"; } else { replacementsDictionary[RuntimeRelease] = "MultiThreadedDLL"; replacementsDictionary[RuntimeDebug] = "MultiThreadedDebugDLL"; } if (!isPlatformSet) { IEnumerable <TargetPlatformSDK> platformSdks = ToolLocationHelper.GetTargetPlatformSdks(); IEnumerable <TargetPlatformSDK> allSdks = WizardImplementation.GetAllPlatformSdks(); TargetPlatformSDK latestSdk = allSdks.FirstOrDefault(); if (latestSdk == null) { ShowRtlAwareMessageBox(Resources.WinSDKNotFound); throw new WizardCancelledException(Resources.WinSDKNotFound); } string versionString; if (latestSdk.TargetPlatformVersion.Major >= 10) { List <Platform> allPlatformsForLatestSdk = ToolLocationHelper.GetPlatformsForSDK("Windows", latestSdk.TargetPlatformVersion) .Select(moniker => TryParsePlatformVersion(moniker)) .Where(name => name != null) .OrderByDescending(p => p.Version).ToList(); Platform latestPlatform = allPlatformsForLatestSdk.FirstOrDefault(); if (latestPlatform == null) { ShowRtlAwareMessageBox(Resources.WinSDKNotFound); throw new WizardCancelledException(Resources.WinSDKNotFound); } versionString = latestPlatform.Version.ToString(); } else { versionString = latestSdk.TargetPlatformVersion.ToString(); } replacementsDictionary[TargetPlatformVersion] = versionString; } }