在项目模板中使用IWizard而不在GAC中安装程序集? [英] Using IWizard in an item template without installing assembly in GAC?

查看:89
本文介绍了在项目模板中使用IWizard而不在GAC中安装程序集?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想创建一个包含向导(IWizard界面)的自定义项目模板.

I would like to create a custom item template that includes a wizard (IWizard interface).

http://msdn .microsoft.com/en-us/library/vstudio/ms171411%28v = vs.100%29.aspx 和其他一些地方,总是描述必须在GAC中安装包含该向导的程序集.我想在我的组织中分发我的模板,但并不是每个人都有权将任何东西安装到GAC中.

On http://msdn.microsoft.com/en-us/library/vstudio/ms171411%28v=vs.100%29.aspx and some other places it is always described that the assembly containing the wizard has to be installed in GAC. I would like to distribute my template in my organisation, and not everybody has right to install anything into GAC.

所以我想知道,没有办法在模板zip或vsix文件中包含包含向导代码的程序集吗?

So I'm wondering, is there no way to have the assembly containing the wizard code inside the template zip, or vsix file?

在我看来这应该是一个普遍的问题吗?

It seems to me that this should be a common problem?

在不安装任何GAC的情况下如何分发自定义向导和项目模板的任何帮助吗?

Any help how to distribute a custom wizard and item template without any GAC installations?

推荐答案

经过大量研究,我找到了一种方法.使用此方法,即使没有签名,也可以将带有IWizard实现的程序集包含到VSIX文件中,并使其在运行时可用.无需摆弄GAC.

After a lot of research, I found a way to do that. With this method it is possible to include the assembly with the IWizard implementation into the VSIX file, even without signing it, and having it available at runtime. No need to fiddle with the GAC.

您的解决方案中需要3个项目

You need 3 projects in your solution

  1. vsix项目(我们称为 MyExtension )
  2. 项目模板项目(我们称为 MyTemplate )
  3. 用于向导代码的常规类库项目(我们称为 MyWizardImpl )
  1. the vsix project (we call it MyExtension)
  2. an item template project (we call it MyTemplate)
  3. a regular class library project for the wizard code (we call it MyWizardImpl)

在MyWizardImpl内部,您需要在arbitray类中实现IWizard接口. (我们将其称为MyWizardImpl.ItemTemplateWizard1).编译时,您将获得输出

Inside MyWizardImpl you need to implement the IWizard interface, in an arbitray class. (we call it MyWizardImpl.ItemTemplateWizard1). When compiling this, you get as output

<solutiondir>\MyWizardImpl\bin\Debug\MyWizardImpl.dll

现在,在MyTemplate \ MyTemplate.vstemplate中,您需要引用它

Now, in MyTemplate\MyTemplate.vstemplate, you need to reference it

<WizardExtension>
    <Assembly>MyWizardImpl</Assembly>
    <FullClassName>MyWizardImpl.ItemTemplateWizard1</FullClassName>
</WizardExtension>

最棘手的部分是最后一个:将组合件包含在vsix中,以便在应用ItemTemplate时可以将其装入.

The tricky part comes last: Including the assembly inside the vsix in a way that it can be loaded when the ItemTemplate is applied.

  • 创建一个文件夹MyExtension \ Assemblies
  • 在解决方案资源管理器中,右键单击该文件夹,然后选择添加->现有项...
  • 在添加现有项"对话框中,导航到创建的MyWizardImpl.dll.在添加"按钮上,单击小箭头,然后选择添加为链接"(以防止VS复制该dll)
  • 在此链接的属性中,选择BuildAction = Content,IncludeInVSIX = True
  • 在XML编辑器(或记事本)中打开vsixmanifest,然后在该部分中添加一个组装行.

示例:

<Content>
   <Assembly AssemblyName="MyWizardImpl">Assemblies\MyWizardImpl.dll</Assembly>
</Content>

构建并测试解决方案,使用模板时,向导代码应立即运行.

Build and test the solution, the wizard code should run now when using the template.

如果您的vsix中需要多个模板,则只需添加其他ItemTemplate项目.所有向导都可以进入相同的MyWizardImpl程序集.

If you need more than one template in your vsix, you simply need to add additional ItemTemplate projects. All the wizards can go into the same MyWizardImpl assembly.

这篇关于在项目模板中使用IWizard而不在GAC中安装程序集?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆