public void RunStarted(object automationObject, Dictionary<string, string> replacementsDictionary, WizardRunKind runKind, object[] customParams)
    {
      try
      {
        // Display a form to the user. The form collects 
        // input for the custom message.
        inputForm = new SolutionSetupForm();
        inputForm.ShowDialog();

        ProxyName = inputForm.ProxyProjectName;
        ServerName = inputForm.ServerProjectName;
        ClientName = inputForm.ClientProjectName;
        OutputDirectory = string.Format("{0}\\Debug\\", replacementsDictionary["$solutiondirectory$"]);
        if (!Directory.Exists(OutputDirectory))
          Directory.CreateDirectory(OutputDirectory);

        // Add custom parameters.
        replacementsDictionary.Add("$proxyname$", ProxyName);
        replacementsDictionary.Add("$servername$", ServerName);
        replacementsDictionary.Add("$clientname$", ClientName);
        replacementsDictionary.Add("$outputdirectory$", OutputDirectory);
      }
      catch (Exception ex)
      {
        MessageBox.Show(ex.ToString());
      }
    }
Example #2
0
        public void RunStarted(object automationObject, Dictionary<string, string> replacementsDictionary, WizardRunKind runKind, object[] customParams)
        {
            string runSilent;
            if (replacementsDictionary.TryGetValue("$runsilent$", out runSilent) && bool.TrueString.Equals(runSilent, StringComparison.OrdinalIgnoreCase))
                return;

            string wizardData;
            if (!replacementsDictionary.TryGetValue("$wizarddata$", out wizardData))
                return;

            if (string.IsNullOrWhiteSpace(wizardData))
                return;

            string message;
            try
            {
                XDocument document = XDocument.Parse(wizardData);
                message = document.Root.Value;
            }
            catch (XmlException ex)
            {
                StringBuilder error = new StringBuilder();
                error.AppendLine("Could not parse WizardData element.");
                error.AppendLine();
                error.Append(ex);
                message = error.ToString();
            }

            MessageBox.Show(message);
        }
        public void RunStarted(object automationObject, Dictionary<string, string> replacementsDictionary, WizardRunKind runKind, object[] customParams)
        {
            try
            {
                _dte = automationObject as EnvDTE.DTE;
                _projectName = replacementsDictionary["$safeprojectname$"];
                _container = replacementsDictionary["$container$"];
                _solutionDir = System.IO.Path.GetDirectoryName(replacementsDictionary["$destinationdirectory$"]);
                _templateDir = System.IO.Path.GetDirectoryName(customParams[0] as string);

                XamarinFormsNewProjectDialog dialog = new XamarinFormsNewProjectDialog();
                dialog.ShowDialog();
                _dialogResult = dialog.Result;

                if (_dialogResult.Cancelled)
                    throw new WizardBackoutException();
            }
            catch (Exception ex)
            {
                if (Directory.Exists(_solutionDir))
                    Directory.Delete(_solutionDir, true);

                throw;
            }
        }
        public void RunStarted(object automationObject, Dictionary<string, string> replacementsDictionary, WizardRunKind runKind, object[] customParams)
        {
            DTE dte = automationObject as DTE;

            //Get a reference to the Item currently selected in the Solution Explorer
            SelectedItem item = dte.SelectedItems.Item(1);

            //Check if the $edmxInputFile$ token is already in the replacementDictionnary.
            //If it is, it means the file was added through the "Add Code Generation Item..." menu,
            //and we don't need to set it here. The token was actually set by the
            //Microsoft.Data.Entity.Design.VisualStudio.ModelWizard.AddArtifactGeneratorWizard WizardExtension
            //(see the file StarterKitExtension.ItemTemplate.vstemplate in the StarterKitExtension.ItemTemplate project)
            if (!replacementsDictionary.ContainsKey("$edmxInputFile$"))
            {
                ModelChoser frm = new ModelChoser(dte, item);
                if (frm.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                {
                    //Substitute the EDMX filename within the template
                    replacementsDictionary.Add("$edmxInputFile$", frm.ModelFile);
                }
                else
                {
                    throw new WizardCancelledException("Action cancelled by user");
                }

            }
        }
        public void RunStarted(object automationObject, Dictionary<string, string> replacementsDictionary, WizardRunKind runKind, object[] customParams)
        {
            this.ItemTemplateParams = replacementsDictionary;
            _dte = (DTE)automationObject;
            _solution = (Solution4)dte.Solution;

            OnWizardStart(automationObject);
            WizardCancel += new CancelEventHandler(OnWizardCancel);

            if (this.Pages.Count > 0)
            {
                this.CenterToScreen();

                System.Windows.Forms.DialogResult dlgResult = this.ShowDialog();

                if (dlgResult == System.Windows.Forms.DialogResult.OK)
                {
                    OnWizardFinish();

                } else
                if (dlgResult == System.Windows.Forms.DialogResult.Cancel)
                {
                    throw new WizardCancelledException();
                }
         
            }
           
        }
Example #6
0
 public void RunStarted(object automationObject,
     Dictionary<string, string> replacementsDictionary,
     WizardRunKind runKind, object[] customParams)
 {
     safeprojectname = replacementsDictionary["$safeprojectname$"];
     globalParameters["$safeprojectname$"] = safeprojectname;
 }
Example #7
0
        public void RunStarted(object automationObject, Dictionary<string, string> replacementsDictionary, WizardRunKind runKind, object[] customParams)
        {
            _dte = (DTE)automationObject;
            _wrongProjectFolder = replacementsDictionary["$destinationdirectory$"];
            _solutionFolder = Path.GetDirectoryName(_wrongProjectFolder);
            _templatePath = Path.GetFullPath(Path.Combine(Path.GetDirectoryName((string)customParams[0]), ".."));
            _solutionName = replacementsDictionary["$safeprojectname$"];
            replacementsDictionary.Add("$safesolutionname$", _solutionName);

            var dlg = new WizardForm(_solutionName);
            if (dlg.ShowDialog() == DialogResult.OK)
            {
                replacementsDictionary.Add("$connectionstring$", dlg.ConnectinString);
                replacementsDictionary.Add("$databasename$", dlg.DatabaseName);
                replacementsDictionary.Add("$databaseuser$", dlg.DatabaseUser);
                replacementsDictionary.Add("$ormapperclassname$", dlg.ORMapperClassName);
                replacementsDictionary.Add("$ormappermodule$", dlg.ORMapperModule);
                replacementsDictionary.Add("$schema$", dlg.Schema);
                replacementsDictionary.Add("$provider$", dlg.Provider);
            }
            else
            {
                throw new WizardCancelledException("Aborted by user");
            }

            _replacementsDictionary = replacementsDictionary;
        }
Example #8
0
		public override void RunStarted(object automationObject, Dictionary<string, string> replacementsDictionary, WizardRunKind runKind, object[] customParams)
		{
			var doc = Helpers.LoadWizardXml(replacementsDictionary);
			var ns = Helpers.WizardNamespace;

			var model = new OptionsPageModel(doc.Root.Elements(ns + "Options").FirstOrDefault());

			var view = new OptionsPageView(model);
			var dialog = new BaseDialog { Content = view, Title = model.Title };
			if (dialog.ShowModal(Helpers.MainWindow))
			{
				foreach (var option in model.Options)
				{
					var selected = option.Selected;
					if (selected != null)
					{
						foreach (var replacement in selected.Replacements)
						{
							if (replacementsDictionary.MatchesCondition(replacement.Condition))
							{
								replacementsDictionary[replacement.Name] = replacement.Content;
							}
						}
					}
				}
			}
			else
				throw new WizardBackoutException();
			
		}
 public void RunStarted(object automationObject, Dictionary<string, string> replacementsDictionary, WizardRunKind runKind, object[] customParams)
 {
     _dte = automationObject as EnvDTE.DTE;
     _viewName = replacementsDictionary["$safeitemname$"];
     _viewModelName = $"{_viewName}ViewModel";
     _templatesDirectory = Path.GetDirectoryName(customParams[0] as string);
 }
 public override void RunStarted(object automationObject, Dictionary<string, string> replacementsDictionary, WizardRunKind runKind, object[] customParams)
 {
     // This is done to trick NuPattern into using the v4 template when unfolding the v5 template.
     // The template is used by NuPattern to identify the toolkit and product elements associated to the template,
     // and there can only one template associated to the application
     base.RunStarted(automationObject, replacementsDictionary, runKind, ApplicationTemplateWorkaroundHelper.ReplaceCustomParameters(customParams));
 }
        public void RunStarted(object automationObject, Dictionary<string, string> replacementsDictionary, WizardRunKind runKind, object[] customParams) {

            DTE2 dte = automationObject as DTE2;

            // here we need to show the UI for which file to download
            var form = new DownloadZipWindow();
            var result = form.ShowDialog();

            if (result.HasValue && result.Value) {
                // download the file
                string file = form.DownloadedFile;

                TempDir = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString());
                if (!Directory.Exists(TempDir)) {
                    Directory.CreateDirectory(TempDir);
                }

                // unpack the file in temp
                ZipFile.ExtractToDirectory(file, TempDir);

                // copy the files to the project directory
                var foo = "bar";
            }

        }
Example #12
0
 // Retrieve global replacement parameters
 public void RunStarted(object automationObject,
     Dictionary<string, string> replacementsDictionary,
     WizardRunKind runKind, object[] customParams)
 {
     // Add custom parameters.
     replacementsDictionary.Add("$saferootprojectname$", RootWizard.GlobalDictionary["$saferootprojectname$"]);
 }
 public void RunStarted(object automationObject, Dictionary<string, string> replacementsDictionary, WizardRunKind runKind, object[] customParams)
 {
     var timestamp = DateTime.Now.ToString("yyyyMMddHHmmss");
       replacementsDictionary["$migrationtimestamp$"] = timestamp;
       replacementsDictionary["$migrationclassname$"] = replacementsDictionary["$safeitemname$"];
       replacementsDictionary["$migrationfilename$"] = String.Format("{0}_{1}.cs", timestamp, replacementsDictionary["$safeitemname$"]);
 }
Example #14
0
        void IWizard.RunStarted(object automationObject, Dictionary<string, string> replacementsDictionary, WizardRunKind runKind, object[] customParams)
        {
            DTE dte = (DTE)automationObject;

            string deploymentFolder = String.Empty;

            string destinationDirectory = replacementsDictionary["$destinationdirectory$"];
            if (destinationDirectory.EndsWith("\\", StringComparison.Ordinal) == false) {
                destinationDirectory = destinationDirectory + "\\";
            }

            string parentFolder = Path.GetDirectoryName(destinationDirectory);

            DeploymentWizardForm wizardForm = new DeploymentWizardForm(parentFolder);
            if (wizardForm.ShowDialog(new WindowOwner((IntPtr)dte.MainWindow.HWnd)) == DialogResult.OK) {
                Uri destinationUri = new Uri(destinationDirectory);
                Uri deploymentUri = new Uri(wizardForm.DeploymentFolder);

                Uri relativeUri = destinationUri.MakeRelativeUri(deploymentUri);

                deploymentFolder = relativeUri.ToString().Replace("/", "\\");
            }

            replacementsDictionary["$deploymentpath$"] = deploymentFolder;
        }
        public void RunStarted(object automationObject, Dictionary<string, string> replacementsDictionary,
          WizardRunKind runKind, object[] customParams)
        {
            Wizard wiz = new Wizard();

            // Setup wiz:
            wiz.txtNamespace.Text = replacementsDictionary["$safeprojectname$"];

            if (wiz.ShowDialog() == DialogResult.OK)
            {
                // Fill in the replacement values from the UI selections on the wizard page.
                replacementsDictionary.Add("$LanguageID$", Guid.NewGuid().ToString());
                replacementsDictionary.Add("$LanguageName$", wiz.txtBoxLanguageName.Text);
                replacementsDictionary.Add("$LanguageCompanyName$", wiz.txtCompanyName.Text);
                replacementsDictionary.Add("$LanguageNamespace$", wiz.txtNamespace.Text);
                replacementsDictionary.Add("$LanguageProductName$", wiz.txtProductName.Text);
                replacementsDictionary.Add("$LanguageDescription$", wiz.richTextBoxDescription.Text);

                // add guids up to 20
                for(int i = 0; i <= 20; i++ )
                    replacementsDictionary.Add("$Guid" + i.ToString()+ "$", Guid.NewGuid().ToString());

                /*
                System.ComponentModel.Design.CommandID GenerateAllCommandId = new System.ComponentModel.Design.CommandID(new System.Guid("CCD03FEB-6B80-4CDB-AB3A-04702F6E7553"), 8224);
                object obj1 = null, obj2 = null;
                System.Guid guid = GenerateAllCommandId.Guid;
                (automationObject as EnvDTE._DTE).Commands.Raise(guid.ToString("b"), GenerateAllCommandId.ID, ref obj1, ref obj2);
                */

                return;
            }

            throw new WizardCancelledException();
        }
Example #16
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="automationObject">???</param>
        /// <param name="replacementsDictionary">Dictionary containing variables that will be replaced in the template. Addable.</param>
        /// <param name="runKind">Specifies constants that define the different templates the template wizard can create.
        /// AsNewItem / AsNewProject / AsMultiProject</param>
        /// <param name="customParams">The custom parameters with which to perform parameter replacement in the project.</param>
        void IWizard.RunStarted(object automationObject, Dictionary<string, string> replacementsDictionary, WizardRunKind runKind, object[] customParams)
        {
            List<string> l1 = new List<string>();

            foreach (UIHierarchyItem item in (((DTE2)automationObject).ToolWindows.SolutionExplorer.SelectedItems as Array))
            {
                ProjectItem prjItem = item.Object as ProjectItem;
                l1.Add(prjItem.Properties.Item("FullPath").Value.ToString());
            }

            // "$rootname$" is always present
            shouldAddProjectItem = ExecuteForNewItem(replacementsDictionary["$rootname$"], l1[0]);
            if (!shouldAddProjectItem)
                return;

            // NOTE!
            // 1 - Item in template XML must have its parameter ReplaceParameters being set to "true" in order for this to function!
            // 2 - Strings to replace should end up with the line break
            if (viewDialog.IsViewModel)
                replacementsDictionary.Add("$model$", "{% model Model:" + viewDialog.SelectedModel + " %}\r\n");
            else
                replacementsDictionary.Add("$model$", string.Empty);

            if (viewDialog.IsInheritance)
                replacementsDictionary.Add("$extends$", "{% extends \"~\\" + viewDialog.TemplateToExtend + "\" %}\r\n");
            else
                replacementsDictionary.Add("$extends$", string.Empty);

            replacementsDictionary.Add("$pregenerated$", viewDialog.PreGeneratedTemplateText + "\r\n");
        }
        /// <summary>
        /// Runs custom wizard logic at the beginning of a template wizard run.
        /// </summary>
        /// <param name="automationObject">The automation object being used by the template wizard.</param>
        /// <param name="replacementsDictionary">The list of standard parameters to be replaced.</param>
        /// <param name="runKind">A <see cref="T:Microsoft.VisualStudio.TemplateWizard.WizardRunKind"/> indicating the type of wizard run.</param>
        /// <param name="customParams">The custom parameters with which to perform parameter replacement in the project.</param>
        public override void RunStarted(object automationObject, Dictionary<string, string> replacementsDictionary, WizardRunKind runKind, object[] customParams)
        {
            base.RunStarted(automationObject, replacementsDictionary, runKind, customParams);

            Guard.NotNull(() => replacementsDictionary, replacementsDictionary);
            Guard.NotNull(() => customParams, customParams);

            var wizardData = Enumerable.FirstOrDefault<IVsTemplateWizardData>(this.TemplateSchema.WizardData);
            if (wizardData != null)
            {
                var additionalReplacements = from element in wizardData.Elements
                                             where element.Name.Equals(ReplacementElementName, StringComparison.OrdinalIgnoreCase) &&
                                                 !string.IsNullOrEmpty(element.GetAttribute(ReplacementKeyName))
                                             select new
                                             {
                                                 Key = element.GetAttribute(ReplacementKeyName),
                                                 Value = element.GetAttribute(ReplacementValueName)
                                             };

                foreach (var replacement in additionalReplacements)
                {
                    tracer.Verbose(Resources.ReplacementTemplateWizard_Replacing, replacement.Key, replacement.Value);
                    replacementsDictionary[replacement.Key] = replacement.Value;
                }
            }
        }
Example #18
0
        public void RunStarted(object automationObject, Dictionary<string, string> replacementsDictionary, WizardRunKind runKind, object[] customParams)
        {
            dteObject = (DTE)automationObject;
            serviceProvider = (Microsoft.VisualStudio.OLE.Interop.IServiceProvider)this.dteObject;

            IntPtr zero4 = IntPtr.Zero;
            Guid guid = typeof(SComponentModel).GUID;
            serviceProvider.QueryService(ref guid, ref IUnknownGuid, out zero4);
            componentModel = (IComponentModel)GetObjectFromNativeUnknown(zero4);

            replacementsDictionary["$ext_safeprojectname$"] = RootWizard.GlobalDictionary["$ext_safeprojectname$"];
            replacementsDictionary["$ext_projectname$"] = RootWizard.GlobalDictionary["$ext_projectname$"];

            string localDBInstance = "v11.0";
            var localDBInstances = SqlLocalDbApi.GetInstanceNames();
            if (localDBInstances.IndexOf("MSSqlLocalDB") >= 0)
                localDBInstance = "MSSqlLocalDB";
            else if (localDBInstances.IndexOf("v12.0") >= 0)
                localDBInstance = "v12.0";
            else if (localDBInstances.IndexOf("v11.0") >= 0)
                localDBInstance = "v11.0";
            else if (localDBInstances.Count > 0)
                localDBInstance = localDBInstances[0];

            replacementsDictionary["connectionString=\"Data Source=(LocalDb)\\v11.0;"] =
                "connectionString=\"Data Source=(LocalDb)\\" + localDBInstance + ";";

            if (!replacementsDictionary.TryGetValue("$wizarddata$", out wizardData))
                wizardData = null;
        }
 public void RunStarted(
     object automationObject,
     Dictionary<string, string> replacementsDictionary,
     WizardRunKind runKind,
     object[] customParams)
 {
 }
Example #20
0
 public void RunStarted(object automationObject, System.Collections.Generic.Dictionary<string, string> replacementsDictionary, WizardRunKind runKind, object[] customParams)
 {
     wizard = new WizardDialogBox();
      bool dialogResult = (bool)wizard.ShowDialog();
      if (!dialogResult)
     throw new WizardCancelledException("The user has cancelled the wizard.");
 }
        public void RunStarted(object automationObject, Dictionary<string, string> replacementsDictionary, WizardRunKind runKind, object[] customParams)
        {
            try
            {
                m_Form=new raaClassTemplateForm(replacementsDictionary["$rootnamespace$"]);
                m_Form.ShowDialog();

                if (m_Form.singleton())
                {

                }
                else
                {

                }

                if (m_Form.qobject())
                {

                }
                else
                {

                }

            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
        /// <summary>
        /// Executes when the wizard starts.
        /// </summary>
        public override void RunStarted(object automationObject, Dictionary<string, string> replacementsDictionary,
            WizardRunKind runKind, object[] customParams)
        {
            base.RunStarted(automationObject, replacementsDictionary, runKind, customParams);

            Guard.NotNull(() => replacementsDictionary, replacementsDictionary);
            Guard.NotNull(() => customParams, customParams);

            object contextSolutionName = CallContext.LogicalGetData(SolutionNameKey);
            object contextSafeSolutionName = CallContext.LogicalGetData(SafeSolutionNameKey);

            if (contextSolutionName != null)
            {
                tracer.Verbose(Resources.SolutionNameTemplateWizard_ContextSolutionName, contextSolutionName);

                replacementsDictionary[SolutionNameKey] = (string)contextSolutionName;

                if (contextSafeSolutionName != null)
                {
                    replacementsDictionary[SafeSolutionNameKey] = (string)contextSafeSolutionName;
                }
            }
            else
            {
                tracer.Verbose(Resources.SolutionNameTemplateWizard_NewContextSolution, replacementsDictionary[@"$projectname$"]);

                replacementsDictionary[SolutionNameKey] = replacementsDictionary[@"$projectname$"];
                replacementsDictionary[SafeSolutionNameKey] = replacementsDictionary[@"$safeprojectname$"];

                CallContext.LogicalSetData(SolutionNameKey, replacementsDictionary[SolutionNameKey]);
                CallContext.LogicalSetData(SafeSolutionNameKey, replacementsDictionary[SafeSolutionNameKey]);
            }
        }
        public void RunStarted(object automationObject,
          Dictionary<string, string> replacementsDictionary,
          WizardRunKind runKind, object[] customParams)
        {
            _dte = automationObject as EnvDTE80.DTE2;
            _runKind = runKind;

            if(runKind.HasFlag(WizardRunKind.AsNewProject))
            {
                _solutionDir = replacementsDictionary["$solutiondirectory$"];
                _destinationDirectory = replacementsDictionary["$destinationdirectory$"];           
            }         

            try
            {
                // Display a form to the user. The form collects 
                // input for the custom message.
                //inputForm = new UserInputForm();
                //inputForm.ShowDialog();

                //customMessage = inputForm.get_CustomMessage();

                //// Add custom parameters.
                //replacementsDictionary.Add("$custommessage$",
                //    customMessage);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
            //Console.Write("Wizard!!!");
        }
        public override void RunStarted(object automationObject, Dictionary<string, string> replacementsDictionary, WizardRunKind runKind, object[] customParams)
        {
            base.RunStarted(automationObject, replacementsDictionary, runKind, customParams);

            var vs = (automationObject as DTE);
            this.serviceProvider = new ServiceProvider((Ole.IServiceProvider)vs);
        }
Example #25
0
        public void RunStarted(
            object automationObject,
            Dictionary<string, string> replacementsDictionary,
            WizardRunKind runKind,
            object[] customParams
        ) {
            string winSDKVersion = string.Empty;
            try {
                string keyValue = string.Empty;
                // Attempt to get the installation folder of the Windows 10 SDK
                RegistryKey key = Registry.LocalMachine.OpenSubKey(@"Software\Microsoft\Windows Kits\Installed Roots");
                if (null != key) {
                    keyValue = (string)key.GetValue("KitsRoot10") + "Include";
                }
                // Get the latest SDK version from the name of the directory in the Include path of the SDK installation.
                if (!string.IsNullOrEmpty(keyValue)) {
                    string dirName = Directory.GetDirectories(keyValue, "10.*").OrderByDescending(x => x).FirstOrDefault();
                    winSDKVersion = Path.GetFileName(dirName);
                }
            } catch(Exception ex) {
                if (ex.IsCriticalException()) {
                    throw;
                }
            }
            
            if(string.IsNullOrEmpty(winSDKVersion)){
                winSDKVersion = "10.0.0.0"; // Default value to put in project file
            }

            replacementsDictionary.Add("$winsdkversion$", winSDKVersion);
            replacementsDictionary.Add("$winsdkminversion$", winSDKVersion);
        }
 public void RunStarted(object automationObject,
     Dictionary<string, string> replacementsDictionary,
     WizardRunKind runKind, object[] customParams)
 {
     string safeprojectname = RootWizardImpl.GlobalParameters.Where(p => p.Key == "$safeprojectname$").First().Value;
     replacementsDictionary["$safeprojectname$"] = safeprojectname;
 }
        public void RunStarted(object automationObject, Dictionary<string, string> replacementsDictionary, WizardRunKind runKind, object[] customParams)
        {
            try
            {
                OpenxliveComfirmForm form = new OpenxliveComfirmForm();
                form.ShowDialog();

                if (form.DialogResult == System.Windows.Forms.DialogResult.OK)
                {
                    CreateWithOpenxlive = form.CreateWithOpenxlive;
                    SolutionName = replacementsDictionary["$projectname$"];

                    if (CreateWithOpenxlive)
                        replacementsDictionary.Add("$CreateWithOpenxlive$", "True");
                    else
                        replacementsDictionary.Add("$CreateWithOpenxlive$", "False");
                }
                else
                {
                    throw new WizardCancelledException();
                }
            }
            catch
            {

            }
        }
        public void RunStarted(object automationObject,
            Dictionary<string, string> replacementsDictionary,
            WizardRunKind runKind, object[] customParams)
        {
            try
            {
                // for site instances
                ICCSISiteImplementation.InitDictionary();
                ICCSISiteImplementation.siteDictionary["$webmodule.safeprojectname$"] = replacementsDictionary["$safeprojectname$"].ToString();
                ICCSISiteImplementation.siteDictionary["$webmodule.guid$"] = replacementsDictionary["$guid1$"].ToString();

                // Add custom parameters.
                InitDictionary();
                
                foreach (var item in webModuleDictionary)
                {
                    replacementsDictionary.Add(item.Key, item.Value);
                }

            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
Example #29
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="automationObject">An Object parameter that can be cast to the root _DTE object, to enable you to customize the project.</param>
        /// <param name="replacementsDictionary">A Dictionary<TKey, TValue> parameter that contains a collection of all pre-defined parameters in the template. For more information on template parameters, see Template Parameters.</param>
        /// <param name="runKind">A WizardRunKind parameter that contains information about what kind of template is being used.</param>
        /// <param name="customParams">An Object array that contains a set of parameters passed to the wizard by Visual Studio.</param>
        public void RunStarted(object automationObject, Dictionary<string, string> replacementsDictionary, WizardRunKind runKind, object[] customParams)
        {
            _form = new WizardForm();
            _form.ShowDialog();

            var result = _form.Choice;
            // TODO
        }
Example #30
0
 // Add global replacement parameters
 public void RunStarted(object automationObject,
     Dictionary<string, string> replacementsDictionary,
     WizardRunKind runKind, object[] customParams)
 {
     // Place "$saferootprojectname$ in the global dictionary.
     // Copy from $safeprojectname$ passed in my root vstemplate
     GlobalDictionary["$saferootprojectname$"] = replacementsDictionary["$safeprojectname$"];
 }
Example #31
0
 public void RunStarted(object automationObject, Dictionary <string, string> replacementsDictionary, WizardRunKind runKind, object[] customParams)
 {
     WriteOutBetaNugetSource("dotnet.myget.org roslyn", "https://dotnet.myget.org/F/roslyn/api/v3/index.json");
     WriteOutBetaNugetSource("dotnet.myget.org roslyn-analyzers", "https://dotnet.myget.org/F/roslyn-analyzers/api/v3/index.json");
     OnRunStarted(automationObject as DTE, replacementsDictionary, runKind, customParams);
 }
 public override void RunStarted(object automationObject, Dictionary <string, string> replacementsDictionary, WizardRunKind runKind, object[] customParams)
 {
     // This is done to trick NuPattern into using the v4 template when unfolding the v5 template.
     // The template is used by NuPattern to identify the toolkit and product elements associated to the template,
     // and there can only one template associated to the application
     base.RunStarted(automationObject, replacementsDictionary, runKind, ApplicationTemplateWorkaroundHelper.ReplaceCustomParameters(customParams));
 }
        /// <inheritdoc />
        public void RunStarted(object automationObject, Dictionary <string, string> replacementsDictionary, WizardRunKind runKind, object[] customParams)
        {
            if (automationObject is DTE dte)
            {
                DTE      = dte;
                Solution = DTE.Solution;
            }

            SolutionItemInfrastructure infra = SolutionItemFactory.Create();

            infra.ViewModel.SolutionDirectory = replacementsDictionary[ReplacementNames.SolutionDirectory];
            infra.ViewModel.SolutionName      = Path.GetFileNameWithoutExtension(DTE.Solution.FullName);

            bool?result = infra.View.ShowModal();

            if (result == true)
            {
                Options = infra.Model;
            }
        }
        public void RunStarted(object automationObject, Dictionary <string, string> replacementsDictionary, WizardRunKind runKind, object[] customParams)
        {
            projectName = replacementsDictionary["$safeprojectname$"];
            localReplacementsDictionary = new Dictionary <string, string>(replacementsDictionary);

            string latestVersion = GetLatestVersionOfPackage("ServiceStack.Interfaces");

            localReplacementsDictionary.Add("$currentServiceStackVersion$", latestVersion);

            templatesRootDir = Path.GetDirectoryName(customParams[0] as string);
            localReplacementsDictionary.Add("$saferootprojectname$", projectName);
            if (templatesRootDir == null)
            {
                throw new WizardBackoutException("Failed to create project, 'customParams' does not contain extension template path.");
            }
            solutionDir = Path.GetDirectoryName(localReplacementsDictionary["$destinationdirectory$"]);
            string   wizardData           = localReplacementsDictionary["$wizarddata$"];
            XElement element              = XElement.Parse("<WizardData>" + wizardData + "</WizardData>");
            XElement externalTemplateRoot = null;

            if (element.Descendants().FirstOrDefault(x => x.Name.LocalName == "ExternalTemplate") != null)
            {
                externalTemplateRoot =
                    element.Descendants().First(x => x.Name.LocalName == "ExternalTemplate");
            }
            if (externalTemplateRoot == null)
            {
                return;
            }
            safeProjectNameReplace = externalTemplateRoot.GetAttributeValue("safeProjectNameReplace");
            externalTemplateName   = externalTemplateRoot.GetExternalTemplateName();
            externalTemplateDir    = Path.Combine(templatesRootDir, externalTemplateName);
            externalSolutionPath   = Path.Combine(externalTemplateDir,
                                                  externalTemplateRoot.GetExternalTemplateSolutionFileName());
            externalProjectPath = Path.Combine(externalTemplateDir,
                                               externalTemplateRoot.GetExternalTemplateProjectFileName());
            allTemplatedFiles = externalTemplateRoot.GetListOfTemplatedFiles();

            slnOutputName  = externalTemplateRoot.GetAttributeValue("outputSolutionName");
            projOutputName = externalTemplateRoot.GetAttributeValue("outputProjectName");
        }
Example #35
0
 public void RunStarted(object automationObject, Dictionary <string, string> replacementsDictionary, WizardRunKind runKind, object[] customParams)
 {
     _targetPath = replacementsDictionary["$destinationdirectory$"];
 }
        void IWizard.RunStarted(object automationObject, Dictionary <string, string> replacementsDictionary, WizardRunKind runKind, object[] customParams)
        {
            DTE dte = (DTE)automationObject;

            string deploymentFolder = String.Empty;

            string destinationDirectory = replacementsDictionary["$destinationdirectory$"];

            if (destinationDirectory.EndsWith("\\", StringComparison.Ordinal) == false)
            {
                destinationDirectory = destinationDirectory + "\\";
            }

            string parentFolder = Path.GetDirectoryName(destinationDirectory);

            DeploymentWizardForm wizardForm = new DeploymentWizardForm(parentFolder);

            if (wizardForm.ShowDialog(new WindowOwner((IntPtr)dte.MainWindow.HWnd)) == DialogResult.OK)
            {
                Uri destinationUri = new Uri(destinationDirectory);
                Uri deploymentUri  = new Uri(wizardForm.DeploymentFolder);

                Uri relativeUri = destinationUri.MakeRelativeUri(deploymentUri);

                deploymentFolder = relativeUri.ToString().Replace("/", "\\");
            }

            replacementsDictionary["$deploymentpath$"] = deploymentFolder;
        }
Example #37
0
        public override void RunStarted(
            object automationObject,
            Dictionary <string, string> replacementsDictionary,
            WizardRunKind runKind, object[] customParams)
        {
            _replacementsDictionary = replacementsDictionary;

            base.RunStarted(automationObject, _replacementsDictionary, runKind, customParams);

            var domainNamespace = _replacementsDictionary["$rootnamespace$"];

            if (domainNamespace.EndsWith(".Entities"))
            {
                domainNamespace = domainNamespace.Substring(0, domainNamespace.Length - ".Entities".Length);
            }
            var dnsItems = domainNamespace.Split(new char[] { '.' }, StringSplitOptions.RemoveEmptyEntries);

            //显示向导窗口
            var win = new DomainEntityWizardWindow(automationObject as DTE);

            win.txtClassName.Text      = _replacementsDictionary["$safeitemname$"];
            win.txtBaseEntityName.Text = dnsItems[dnsItems.Length - 1] + "Entity";
            win.txtDomainName.Text     = "实体的领域名称";
            win.txtEntityKeyType.Text  = "int";
            var res = win.ShowDialog();

            if (res != true)
            {
                _canceled = true;
                return;
            }

            //获取用户输入
            _domainEntityName     = win.txtClassName.Text;
            _parentEntityName     = win.txtParentEntityName.Text;
            _domainBaseEntityName = win.txtBaseEntityName.Text;
            string entityKeyType     = win.txtEntityKeyType.Text;
            var    domainEntityLabel = win.txtDomainName.Text;
            var    hasRepository     = win.cbGenerateRepository.IsChecked.Value;
            var    isConfigView      = false;

            //开始动态输出模板内容
            _isChild = !string.IsNullOrWhiteSpace(_parentEntityName);
            var entityAttributes = _isChild ? "[ChildEntity, Serializable]" : "[RootEntity, Serializable]";

            RenderParentRefProperty(entityKeyType);

            RenderRepository(hasRepository, domainEntityLabel);

            RenderViewConfiguration(isConfigView, domainEntityLabel);

            _replacementsDictionary.Add("$domainNamespace$", domainNamespace);
            _replacementsDictionary.Add("$domainEntityLabel$", domainEntityLabel);
            _replacementsDictionary.Add("$entityAttributes$", entityAttributes);
            _replacementsDictionary.Add("$domainEntityName$", _domainEntityName);
            _replacementsDictionary.Add("$domainBaseEntityName$", _domainBaseEntityName);
            _replacementsDictionary.Add("$tableConfig$", @"//配置实体的所有属性都映射到数据表中。
            Meta.MapTable().MapAllProperties();");
            //以下替换字符,由自动生成的命令使用,这里不使用。
            _replacementsDictionary.Add("$normalProperties$", string.Empty);
            _replacementsDictionary.Add("$concreteNew$", string.Empty);
            _replacementsDictionary.Add("$columnConfig$", string.Empty);
        }
Example #38
0
        public void RunStarted(object automationObject, Dictionary <string, string> replacementsDictionary, WizardRunKind runKind, object[] customParams)
        {
            var projectName = replacementsDictionary["$projectname$"];

            replacementsDictionary.Add("$npmsafeprojectname$", NormalizeNpmPackageName(projectName));
            replacementsDictionary.Add("$typescriptversion$", GetLatestAvailableTypeScriptVersionFromSetup());
        }
Example #39
0
        public void RunStarted(object automationObject, Dictionary <string, string> replacementsDictionary, WizardRunKind runKind, object[] customParams)
        {
            _targetPath = replacementsDictionary["$destinationdirectory$"];

            if (runKind == WizardRunKind.AsMultiProject)
            {
                _dte = (DTE2)automationObject;
            }
        }
Example #40
0
        public void RunStarted(object automationObject, Dictionary <string, string> replacementsDictionary, WizardRunKind runKind, object[] customParams)
        {
            _dte = (DTE)automationObject;

            // Ask the user for the necessary parameters.
            WizardView inputForm = null;

            while (inputForm == null || inputForm.PassesValidation() == false)
            {
                // If this is our first time in the loop, init with default parameters.
                if (inputForm == null)
                {
                    inputForm = new WizardView(RootNameSpace, OwnerName, OwnerEmail, OwnerWebsite, DevEnvironmentUrl);
                }
                // Otherwise, init with the parameters the user entered last time.
                else
                {
                    inputForm = new WizardView(inputForm.RootNameSpace, inputForm.OwnerName, inputForm.OwnerEmail, inputForm.OwnerWebsite, inputForm.DevEnvironmentUrl);
                }

                // ShowDialog will return false when the user cancels the dialog.
                if (inputForm.ShowDialog() == false)
                {
                    throw new WizardCancelledException("Action was cancelled by the user.");
                }
            }

            // Update our parameters with the user input.
            RootNameSpace     = inputForm.RootNameSpace;
            OwnerName         = inputForm.OwnerName;
            OwnerEmail        = inputForm.OwnerEmail;
            OwnerWebsite      = inputForm.OwnerWebsite;
            DevEnvironmentUrl = inputForm.DevEnvironmentUrl;

            // Remove them first so there isn't any conflict, they get added by the project templates themselves originally
            replacementsDictionary.Remove("$rootnamespace$");
            replacementsDictionary.Remove("$ownername$");
            replacementsDictionary.Remove("$owneremail$");
            replacementsDictionary.Remove("$ownerwebsite$");
            replacementsDictionary.Remove("$devenvironmenturl$");

            replacementsDictionary.Add("$rootnamespace$", RootNameSpace);
            replacementsDictionary.Add("$ownername$", OwnerName);
            replacementsDictionary.Add("$owneremail$", OwnerEmail);
            replacementsDictionary.Add("$ownerwebsite$", OwnerWebsite);
            replacementsDictionary.Add("$devenvironmenturl$", DevEnvironmentUrl);
        }
        public void RunStarted(object automationObject, Dictionary <string, string> replacementsDictionary, WizardRunKind runKind, object[] customParams)
        {
            SatifyDependencies();

            ParseParameters(replacementsDictionary);

            if (ViewModel == null)
            {
                ViewModel = new MultiPlatformViewModel();
            }

            foreach (var platform in platformProvider.GetSupportedPlatforms())
            {
                ViewModel.Platforms.Add(platform);
            }

            if (ShowDialog)
            {
                if (View == null)
                {
                    View             = new MultiPlatformView();
                    View.DataContext = ViewModel;
                    uiShell.SetOwner(View);
                }

                if (!View.ShowDialog().GetValueOrDefault())
                {
                    throw new WizardBackoutException();
                }
            }
        }
Example #42
0
        void IWizard.RunStarted(object automationObject, Dictionary <string, string> replacementsDictionary, WizardRunKind runKind, object[] customParams)
        {
            // We simply use ThreadHelper.JoinableTaskFactory.Run instead of PumpingJTF.Run, unlike,
            // VsPackageInstaller and VsPackageUninstaller. Because, no powershell scripts get executed
            // as part of the operations performed below. Powershell scripts need to be executed on the
            // pipeline execution thread and they might try to access DTE. Doing that under
            // ThreadHelper.JoinableTaskFactory.Run will consistently make the UI stop responding
            NuGetUIThreadHelper.JoinableTaskFactory.Run(async delegate
            {
                await NuGetUIThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync();

                // alternatively could get body of WizardData element from replacementsDictionary["$wizarddata$"] instead of parsing vstemplate file.
                RunStarted(automationObject, replacementsDictionary, runKind, customParams);
            });
        }
Example #43
0
        private void RunStarted(object automationObject, Dictionary <string, string> replacementsDictionary, WizardRunKind runKind, object[] customParams)
        {
            if (runKind != WizardRunKind.AsNewProject &&
                runKind != WizardRunKind.AsNewItem)
            {
                ShowErrorMessage(VsResources.TemplateWizard_InvalidWizardRunKind);
                throw new WizardBackoutException();
            }

            _dte = (DTE)automationObject;
            PreinstalledPackageInstaller.InfoHandler = message => _dte.StatusBar.Text = message;

            if (customParams.Length > 0)
            {
                var vsTemplatePath = (string)customParams[0];
                _configurations = GetConfigurationsFromVsTemplateFile(vsTemplatePath);
            }

            if (replacementsDictionary != null)
            {
                AddTemplateParameters(replacementsDictionary);
            }
        }
 public void RunStarted(object automationObject, Dictionary <string, string> replacementsDictionary, WizardRunKind runKind, object[] customParams)
 {
 }
Example #45
0
        public void RunStarted(object automationObject, Dictionary <string, string> replacementsDictionary, WizardRunKind runKind, object[] customParams)
        {
            Dte = (DTE)automationObject;
            _registerWorkerParamatersClass = false;

            var form   = new WorkerWizardForm();
            var result = form.ShowDialog();

            if (result != DialogResult.OK)
            {
                throw new WizardCancelledException();
            }

            _registerWorkerParamatersClass = form.get_GenerateParams();

            // add an entry to the dictionary to specify the string used for the $viewinfotablename$ token
            replacementsDictionary.Add("$worker_datattype$", form.get_DataType());
            replacementsDictionary.Add("$worker_priority$", form.get_Priority());
            replacementsDictionary.Add("$worker_params_caption$", form.get_Caption());
            replacementsDictionary.Add("$worker_params_register$", _registerWorkerParamatersClass ? "1" : "0");

            initDefaultNamespace(replacementsDictionary);
        }
        public void RunStarted(object automationObject, Dictionary <string, string> replacementsDictionary, WizardRunKind runKind,
                               object[] customParams)
        {
            string destinationDirectory = replacementsDictionary["$destinationdirectory$"];

            try {
                // Display a form to the user. The form collects input for the custom message.
                inputForm = new UserInputForm();

                if (inputForm.ShowDialog(replacementsDictionary["$safeprojectname$"]) != DialogResult.OK)
                {
                    throw new WizardBackoutException();
                }

                foreach (Tuple <string, string> param in UserInputForm.parameters)
                {
                    replacementsDictionary.Add(param.Item1, param.Item2);
                }
            }
            catch (Exception ex) {
                // Clean up the template that was written to disk
                if (Directory.Exists(destinationDirectory))
                {
                    Directory.Delete(destinationDirectory, true);
                }

                Debug.WriteLine(ex);

                throw;
            }
        }
Example #47
0
        public void RunStarted(object automationObject, Dictionary <string, string> replacementsDictionary, WizardRunKind runKind, object[] customParams)
        {
            dte = (DTE2)automationObject;

            //foreach (string key in replacementsDictionary.Keys)
            //{
            //    System.Diagnostics.Debug.Write(key + " : ");
            //    System.Diagnostics.Debug.WriteLine(replacementsDictionary[key]);
            //}

            string safeprojectname = replacementsDictionary["$safeprojectname$"];

            safeprojectname.IndexOf("Package", StringComparison.CurrentCultureIgnoreCase);

            if (safeprojectname.Contains("Package", , StringComparison.CurrentCultureIgnoreCase))
            {
                // remove Package from $safeprojectname$
                replacementsDictionary["$safeprojectname$"] = safeprojectname.Substring(0, safeprojectname.Length - 7);
            }
        }
Example #48
0
        /// <summary>
        ///     This API supports the Entity Framework infrastructure and is not intended to be used directly from your code.
        /// </summary>
        /// <param name="automationObject"> This API supports the Entity Framework infrastructure and is not intended to be used directly from your code. </param>
        /// <param name="replacementsDictionary"> This API supports the Entity Framework infrastructure and is not intended to be used directly from your code. </param>
        /// <param name="runKind"> This API supports the Entity Framework infrastructure and is not intended to be used directly from your code. </param>
        /// <param name="customParams"> This API supports the Entity Framework infrastructure and is not intended to be used directly from your code. </param>
        public void RunStarted(
            object automationObject, Dictionary <string, string> replacementsDictionary, WizardRunKind runKind, object[] customParams)
        {
            Project project = null;

            var dte = automationObject as DTE2;

            if (EdmxUri == null)
            {
                // Wizard not launched from Escher Designer
                project = VsUtils.GetActiveProject(dte);
                Debug.Assert(project != null, "Unable to retrieve ActiveSolutionProject from DTE");
            }
            else
            {
                // Try to get ProjectItem & project
                var projectItem = VsUtils.GetProjectItemForDocument(EdmxUri.LocalPath, Services.ServiceProvider);
                Debug.Assert(projectItem != null, "Unable to find project item for document");
                if (projectItem != null)
                {
                    // get the project that the input file is running in.
                    project = projectItem.ContainingProject;

                    // turn off code generation on the EDMX file
                    var editingContextMgr = PackageManager.Package.DocumentFrameMgr.EditingContextManager;

                    Debug.Assert(
                        editingContextMgr.DoesContextExist(EdmxUri),
                        "If the AddArtifactGeneratorWizard was launched from Escher, there should be an existing editing context");

                    if (editingContextMgr.DoesContextExist(EdmxUri))
                    {
                        var cpc = new CommandProcessorContext(
                            editingContextMgr.GetNewOrExistingContext(EdmxUri), EfiTransactionOriginator.AddNewArtifactGenerationItemId,
                            Resources.Tx_SetCodeGenerationStrategy);
                        var cmd = EdmUtils.SetCodeGenStrategyToNoneCommand(cpc.Artifact);
                        if (cmd != null)
                        {
                            CommandProcessor.InvokeSingleCommand(cpc, cmd);
                        }
                    }
                }
                else
                {
                    // Couldn't get projectItem for some reason, so default to the active project
                    project = VsUtils.GetActiveProject(dte);
                }

                // Wizard is launched from Escher Designer.  Name of the file in the designer is in the static EdmxUri property.
                var artifactProjectItem    = VsUtils.GetProjectItemForDocument(EdmxUri.LocalPath, Services.ServiceProvider);
                var edmxFilePathInTemplate = String.Empty;
                if (VsUtils.IsLinkProjectItem(artifactProjectItem))
                {
                    // In order to determine the filename that will be placed in the .tt file, we need to first determine the
                    // relative path of the *project item* to the root of the project, since the .tt file will be added as a sibling
                    // of the EDMX file and the project item itself is referencing a linked file. The scenario in mind is:
                    // ProjectRoot
                    //    '- FooFolder
                    //          '- Model.edmx (linked outside the project)
                    //          '- Model.tt <-- we want the .tt file here and the path in the template is relative to this location.
                    var parentItem = artifactProjectItem.Collection.Parent as ProjectItem;
                    var relativeProjectItemParentDir = String.Empty;
                    while (parentItem != null)
                    {
                        relativeProjectItemParentDir = Path.Combine(parentItem.Name, relativeProjectItemParentDir);
                        parentItem = parentItem.Collection.Parent as ProjectItem;
                    }

                    var projectDirectory = VsUtils.GetProjectRoot(project, Services.ServiceProvider);
                    if (projectDirectory != null)
                    {
                        var absoluteProjectItemParentDir = Path.Combine(projectDirectory.FullName, relativeProjectItemParentDir);

                        // Now we determine the relative path between the folder in the project that contains the ProjectItem and the actual path
                        // of the artifact.
                        var artifactParentDirInfo            = new DirectoryInfo(Path.GetDirectoryName(EdmxUri.LocalPath));
                        var absoluteProjectItemParentDirInfo = new DirectoryInfo(absoluteProjectItemParentDir);
                        var relativeDirPath = EdmUtils.GetRelativePath(artifactParentDirInfo, absoluteProjectItemParentDirInfo);
                        var fileName        = Path.GetFileName(EdmxUri.LocalPath);
                        edmxFilePathInTemplate = Path.Combine(relativeDirPath, fileName);
                    }
                }
                else
                {
                    var fi = new FileInfo(EdmxUri.LocalPath);
                    edmxFilePathInTemplate = fi.Name;
                }

                Debug.Assert(!String.IsNullOrEmpty(edmxFilePathInTemplate), "edmxFilePathInTemplate was found to be null or empty");

                replacementsDictionary.Add("$edmxInputFile$", edmxFilePathInTemplate);
            }
        }
Example #49
0
        public void RunStarted(object automationObject, Dictionary <string, string> replacementsDictionary, WizardRunKind runKind, object[] customParams)
        {
            if (runKind == WizardRunKind.AsNewProject)
            {
                this.Initialize((_DTE)automationObject, replacementsDictionary);
                if (this.extensionConfiguration != null)
                {
                    this.SearchFilesAddingToParameters(replacementsDictionary);
                }

                replacementsDictionary.TryGetValue(PARAMETER_NAME_PROJECT_NAME, out this.projectName);
            }
        }
 public void RunStarted(object automationObject, Dictionary <string, string> replacementsDictionary, WizardRunKind runKind, object[] customParams)
 {
     if (runKind == WizardRunKind.AsNewProject)
     {
         DTE = (DTE)automationObject;
         var form = new FormProject(FormType.Workflow, DTE);
         if (form.ShowDialog() == DialogResult.OK)
         {
             ProjectName = form.ProjectName;
             replacementsDictionary.Remove("$projectname$");
             replacementsDictionary.Add("$projectname$", ProjectName);
             replacementsDictionary.Add("$version$", form.CrmVersion);
             replacementsDictionary.Add("$NetVersion$", form.NetVersion);
             replacementsDictionary.Add("$AssemblyName$", form.AssemblyName);
             replacementsDictionary.Add("$RootNamespace$", form.RootNamespace);
             replacementsDictionary.Add("$ProjectName$", ProjectName);
             replacementsDictionary.Add("$CrmConnectionString$", form.CrmConnectionString);
             var ProjectPath = $"{replacementsDictionary["$solutiondirectory$"]}\\{ProjectName}";
             replacementsDictionary.Remove("$destinationdirectory$");
             replacementsDictionary.Add("$destinationdirectory$", ProjectPath);
             if (replacementsDictionary.ContainsKey("$destinationdirectory$"))
             {
                 _destDirectory = replacementsDictionary["$destinationdirectory$"];
             }
             if (replacementsDictionary.ContainsKey("$ProjectName$"))
             {
                 _keyName = replacementsDictionary["$ProjectName$"] + ".snk";
             }
             replacementsDictionary.Add("$ShareProject$", $"{form.RootNamespace.Split(".".ToCharArray())[0]}.{form.RootNamespace.Split(".".ToCharArray())[1]}.Shared");
             replacementsDictionary.Add("$PLDynamicsCrmDevKitCliVersion$", form.PLDynamicsCrmDevKitCliVersion);
         }
         else
         {
             throw new WizardCancelledException("Cancel Click");
         }
     }
     else
     {
         throw new WizardCancelledException("Cancel Click");
     }
 }
        public void RunStarted(object automationObject, Dictionary <string, string> replacementsDictionary, WizardRunKind runKind, object[] customParams)
        {
            try
            {
                _dte = (DTE)automationObject;

                if (replacementsDictionary.ContainsKey("$destinationdirectory$"))
                {
                    _destDirectory = replacementsDictionary["$destinationdirectory$"];
                }

                if (replacementsDictionary.ContainsKey("$wizarddata$"))
                {
                    string wizardData = replacementsDictionary["$wizarddata$"];
                    ReadWizardData(wizardData);
                }

                //Find default SDK version
                var    props             = _dte.Properties["CRM Developer Extensions", "General"];
                string defaultSdkVersion = props.Item("DefaultCrmSdkVersion").Value;

                //TypeScript projects
                if (_crmProjectType == "TypeScript")
                {
                    Version version = Version.Parse(_dte.Version);
                    if (version.Major < 12)
                    {
                        throw new WizardBackoutException("TypeScript projects require Visual Studio 2013 or later");
                    }

                    TypeScriptPicker tsPicker = new TypeScriptPicker(defaultSdkVersion);
                    tsPicker.ShowDialog();

                    _sdkVersion = tsPicker.Version;

                    return;
                }

                //If UnitTest Item - load the assembly & class names from the referenced project into the picker
                if (_isUnitTestItem == "True")
                {
                    List <string> referencedProjects     = new List <string>();
                    Array         activeSolutionProjects = (Array)_dte.ActiveSolutionProjects;
                    if (activeSolutionProjects != null && activeSolutionProjects.Length > 0)
                    {
                        VSProject vsproject = ((Project)activeSolutionProjects.GetValue(0)).Object;
                        referencedProjects.AddRange(from Reference reference in vsproject.References
                                                    where reference.SourceProject != null
                                                    select reference.Name);

                        List <ComboBoxItem> classItems = GetSourceProjectItems(referencedProjects);
                        var testClassPickerform        = new TestClassPicker(classItems);
                        testClassPickerform.ShowDialog();

                        replacementsDictionary.Add("$fullclassname$", testClassPickerform.FullClassname);
                        replacementsDictionary.Add("$assemblyname$", testClassPickerform.AssemblyName);
                        _sdkVersion = GetSdkVersion(vsproject.Project);
                        if (_sdkVersion == "CRM 2016 (8.0.X)" || _sdkVersion == "CRM 2016 (8.1.X)" || _sdkVersion == "CRM 2016 (8.2.X)")
                        {
                            replacementsDictionary.Add("$useXrmToolingClientUsing$", "1");
                        }

                        else
                        {
                            replacementsDictionary.Add("$useXrmToolingClientUsing$", "0");
                        }
                    }

                    return;
                }

                //If UnitTest Project - load the projects into the picker
                List <ComboBoxItem> projectItems = new List <ComboBoxItem>();
                if (_isUnitTest == "True")
                {
                    projectItems = GetSourceProjects();
                }

                //Display the form prompting for the SDK version and/or project to unit test against
                if (_crmProjectType == "Plug-in" || _crmProjectType == "Workflow" || _crmProjectType == "Console")
                {
                    var form = new SdkProjectPicker((_isUnitTest == "True"), projectItems, defaultSdkVersion);
                    form.ShowDialog();

                    _sdkVersion = form.Version;
                    _project    = form.Project;
                    _isNunit    = form.Nunit;
                }

                if (_sdkVersion == null)
                {
                    Array activeSolutionProjects = (Array)_dte.ActiveSolutionProjects;
                    if (activeSolutionProjects != null && activeSolutionProjects.Length > 0)
                    {
                        _sdkVersion = GetSdkVersion(((Project)activeSolutionProjects.GetValue(0)).Object);
                    }
                }
                if (_sdkVersion == "CRM 2016 (8.0.X)" || _sdkVersion == "CRM 2016 (8.1.X)" || _sdkVersion == "CRM 2016 (8.2.X)")
                {
                    replacementsDictionary.Add("$useXrmToolingClientUsing$", "1");
                }
                else
                {
                    replacementsDictionary.Add("$useXrmToolingClientUsing$", "0");
                }

                //If UnitTest Project - set the reference to the project being tested
                if (_isUnitTest == "True")
                {
                    if (string.IsNullOrEmpty(_project))
                    {
                        replacementsDictionary.Add("$referenceproject$", "False");
                        return;
                    }

                    Projects projects = _dte.Solution.Projects;
                    Solution solution = _dte.Solution;
                    foreach (Project project in projects)
                    {
                        if (project.Name != _project)
                        {
                            continue;
                        }

                        string path         = string.Empty;
                        string projectPath  = Path.GetDirectoryName(project.FullName);
                        string solutionPath = Path.GetDirectoryName(solution.FullName);
                        if (!string.IsNullOrEmpty(projectPath) && !string.IsNullOrEmpty(solutionPath))
                        {
                            if (projectPath.StartsWith(solutionPath))
                            {
                                path = "..\\" + project.UniqueName;
                            }
                            else
                            {
                                path = project.FullName;
                            }
                        }

                        replacementsDictionary.Add("$referenceproject$", "True");
                        replacementsDictionary.Add("$projectPath$", path);
                        replacementsDictionary.Add("$projectId$", project.Kind);
                        replacementsDictionary.Add("$projectName$", project.Name);
                        break;
                    }
                }
                else
                {
                    replacementsDictionary.Add("$referenceproject$", "False");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error Processing Template: " + ex.Message);
            }
        }
        public void RunStarted(object automationObject, Dictionary <string, string> replacementsDictionary, WizardRunKind runKind, object[] customParams)
        {
            // Override the target framework to work around the issue with loading a 4.5 template
            const string targetFrameworkVersionKey = "$targetframeworkversion$";
            string       targetFrameworkVersion;

            if (!replacementsDictionary.TryGetValue(targetFrameworkVersionKey, out targetFrameworkVersion) || targetFrameworkVersion == "4.0")
            {
                replacementsDictionary[targetFrameworkVersionKey] = "4.5";
            }
        }
Example #53
0
        public void RunStarted(object automationObject, Dictionary <string, string> replacementsDictionary, WizardRunKind runKind, object[] customParams)
        {
            dte = automationObject as EnvDTE.DTE;
            defaultDestinationFolder = replacementsDictionary["$destinationdirectory$"];
            basePath = Path.GetDirectoryName((string)customParams[0]);

            safeProjectName = replacementsDictionary["$safeprojectname$"];

            var doc = Helpers.LoadWizardXml(replacementsDictionary);
            var ns  = Helpers.WizardNamespace;

            foreach (var element in doc.Root.Elements(ns + "Projects").Elements(ns + "Project"))
            {
                var definition = new ProjectDefinition(element, replacementsDictionary);
                if (replacementsDictionary.MatchesCondition(definition.Condition))
                {
                    definitions.Add(definition);
                }
            }

            cachedGlobals = null;
            Globals.Clear();
            foreach (var replacement in replacementsDictionary)
            {
                Globals[replacement.Key] = replacement.Value;
            }
        }
        public void RunStarted(object automationObject, Dictionary <string, string> replacementsDictionary, WizardRunKind runKind, object[] customParams)
        {
            Dte = (DTE)automationObject;
            var result = MessageBox.Show(null, "Czy uzupełnić projekt o elementy rozszerzenia bazy danych ?", "Uzupełnienie dodatku",
                                         MessageBoxButtons.YesNo, MessageBoxIcon.Question);

            _addDbExtension = result == DialogResult.Yes;
        }
 public void RunStarted(object automationObject, Dictionary <string, string> replacementsDictionary, WizardRunKind runKind, object[] customParams)
 {
     try
     {
         DTE = (DTE)automationObject;
         var form = new FormItem(ItemType.TestUi, DTE, string.Empty, string.Empty);
         if (form.ShowDialog() == DialogResult.Cancel)
         {
             throw new WizardCancelledException();
         }
         //Creating item ...
         Wizard.ProcessItemReplacementsDictionary(replacementsDictionary, form);
     }
     catch
     {
         throw;
     }
 }
        public void RunStarted(object automationObject, Dictionary <string, string> replacementsDictionary, WizardRunKind runKind, object[] customParams)
        {
            try
            {
                if (runKind == WizardRunKind.AsNewProject || runKind == WizardRunKind.AsMultiProject)
                {
                    _replacementsDictionary = replacementsDictionary;

                    GenContext.Current = this;

                    _userSelection = NewProjectGenController.Instance.GetUserSelection(GenContext.CurrentLanguage, new VSStyleValuesProvider());
                }
            }
            catch (WizardBackoutException)
            {
                var projectDirectory  = replacementsDictionary["$destinationdirectory$"];
                var solutionDirectory = replacementsDictionary["$solutiondirectory$"];

                if (GenContext.ToolBox.Repo.SyncInProgress)
                {
                    GenContext.ToolBox.Repo.CancelSynchronization();
                }

                CleanupDirectories(projectDirectory, solutionDirectory);

                throw;
            }
        }
        /// <summary> Run started </summary>
        /// <param name="automationObject">Automation Object</param>
        /// <param name="replacementsDictionary">Replacements</param>
        /// <param name="runKind">Run Kind</param>
        /// <param name="customParams">Custom Params</param>
        public void RunStarted(object automationObject,
                               Dictionary <string, string> replacementsDictionary,
                               WizardRunKind runKind, object[] customParams)
        {
            _dte = (DTE)automationObject;

            _solutionFolder    = replacementsDictionary["$solutiondirectory$"];
            _destinationFolder = replacementsDictionary["$destinationdirectory$"];
            _safeprojectname   = replacementsDictionary["$safeprojectname$"];

            try
            {
                // Display Customization Wizard Form
                var inputForm = new UserInputForm();

                // Default the location for the Kendo folder
                _sageWebFolder = RegistryHelper.Sage300CWebFolder;
                inputForm.KendoDefaultFolder = Path.Combine(_sageWebFolder, "Scripts", "Kendo");

                var res = inputForm.ShowDialog();

                // Abort wizard if not proceeding with solution generation
                if (res != DialogResult.OK)
                {
                    throw new WizardBackoutException();
                }

                // Get parameters from screen
                _companyName           = inputForm.BusinessPartnerName;
                _moduleName            = inputForm.ModuleName;
                _projectName           = inputForm.ProjectName;
                _assemblyName          = inputForm.AssemblyName;
                _customizationManifest = inputForm.CustomizationManifest;
                _customizationFileName = inputForm.CustomizationFileName;
                _kendoFolder           = inputForm.KendoFolder.Trim();

                // Add custom parameters for token replacement
                replacementsDictionary.Add("$companyname$", _companyName);
                replacementsDictionary.Add("$module$", _moduleName);
                replacementsDictionary.Add("$project$", _projectName);
                replacementsDictionary.Add("$sage300webfolder$", _sageWebFolder);
            }
            catch
            {
                // Clean up the template that was written to disk
                if (!Directory.Exists(_solutionFolder))
                {
                    throw;
                }

                try
                {
                    Directory.Delete(_solutionFolder);
                }
                catch
                {
                    // Ignore
                }

                throw;
            }
        }
Example #58
0
        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
                };
                var download = new TaskDialogButton(Strings.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             = Strings.ProductTitle,
                        MainInstruction   = Strings.AzureToolsUpgradeRecommended,
                        Content           = Strings.AzureToolsUpgradeInstructions,
                        AllowCancellation = true,
                        VerificationText  = Strings.DontShowAgain
                    };
                    var download = new TaskDialogButton(Strings.DownloadAndInstall);
                    dlg.Buttons.Add(download);
                    var cont = new TaskDialogButton(Strings.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);
        }
Example #59
0
        public override void RunStarted(object automationObject, Dictionary <string, string> replacementsDictionary, WizardRunKind runKind, object[] customParams)
        {
            var doc = Helpers.LoadWizardXml(replacementsDictionary);
            var ns  = Helpers.WizardNamespace;

            var model = new OptionsPageModel(doc.Root.Elements(ns + "Options").FirstOrDefault());

            var view   = new OptionsPageView(model);
            var dialog = new BaseDialog {
                Content = view, Title = model.Title
            };

            if (dialog.ShowModal(Helpers.MainWindow))
            {
                foreach (var option in model.Options)
                {
                    var selected = option.Selected;
                    if (selected != null)
                    {
                        selected.Replacements.SetMatchedItems(replacementsDictionary);
                    }
                }
            }
            else
            {
                throw new WizardBackoutException();
            }
        }
Example #60
0
 public void RunStarted(object automationObject, Dictionary <string, string> replacementsDictionary, WizardRunKind runKind, object[] customParams)
 {
     if (runKind == WizardRunKind.AsMultiProject)
     {
         if (!CommandUtils.TryRegisterAppFromProgramFiles("Git\\bin", "git"))
         {
             var form = new GitBashInstallationPrompt();
             form.ShowDialog();
             if (!form.GitFoundOnPath)
             {
                 //Advise to restart VS and backout?
                 throw new WizardBackoutException("Git installation required");
             }
         }
     }
 }