利用Visual Studio 2017的扩展开发(VSIX、ItemTemplate) 快速实现项目的半自动化搭建 (8)

利用Visual Studio 2017的扩展开发(VSIX、ItemTemplate) 快速实现项目的半自动化搭建

4.添加VSIX开发要用到的相关类库。在FirstProjectWizard项目下的引用鼠标右键,添加

EnvDTE、Microsoft.VisualStudio.TemplateWizardInterface、System.Drawing、System.Windows、System.Windows.Forms等。

5.在FirstProjectWizard项目中添加类,并命名为WizardImplementation,并继承IWizard接口,具体代码如下:

using EnvDTE; using Microsoft.VisualStudio.TemplateWizard; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; namespace FirstProjectWizard { public class WizardImplementation : IWizard { private CustomFieldForm customFieldForm; private string customField; public void BeforeOpeningFile(ProjectItem projectItem) { } public void ProjectFinishedGenerating(Project project) { } public void ProjectItemFinishedGenerating(ProjectItem projectItem) { } public void RunFinished() { } public void RunStarted(object automationObject, Dictionary<string, string> replacementsDictionary, WizardRunKind runKind, object[] customParams) { try { customFieldForm = new CustomFieldForm(); customFieldForm.ShowDialog(); customField = CustomFieldForm.CustomField; //添加自定义参数 replacementsDictionary.Add("customField", customField); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } } public bool ShouldAddProjectItem(string filePath) { return true; } } }

利用Visual Studio 2017的扩展开发(VSIX、ItemTemplate) 快速实现项目的半自动化搭建

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/wpwdfz.html