visual-studio Visual Studio 2008:如何安装项目模板

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/749979/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-22 10:22:23  来源:igfitidea点击:

Visual Studio 2008: How to install an item template

visual-studiotemplates

提问by cbp

I have created an Item Template using the "Export Template" wizard. I opened up the XML file and made a couple of minor changes, then rezipped the package. Then I checked the item template into source control so that everyone on the team can access it if they want.

我已经使用“导出模板”向导创建了一个项目模板。我打开了 XML 文件并做了一些小改动,然后重新压缩了包。然后我将项目模板签入源代码管理,以便团队中的每个人都可以根据需要访问它。

But for the life of me I can't get the template to show up under My Templateswhen I go to Add->New Item.

但是对于我的一生,当我转到Add->New Item时,我无法让模板显示在My Templates下。

I have tried copying the zip file into every conceivable directory:

我尝试将 zip 文件复制到每个可能的目录中:

  • The template directories listed under Tools->Projects and Solutions->General
  • All the subfolders of these directories (i.e. /Visual C#/, /Visual Web Developer/ etc)
  • Tools->Projects and Solutions->General下列出的模板目录
  • 这些目录的所有子文件夹(即 /Visual C#/、/Visual Web Developer/ 等)

But nothing shows up. Has anyone else managed to distribute Item Templates to their team mates before?

但什么也没有出现。之前有没有其他人设法将项目模板分发给他们的队友?

回答by Andy Hopper

In order to have a VS item template appear, you need to make sure that you run "devenv.exe /installvstemplates" after you have copied the .zip file containing your .vstemplate and template code file into the %ProgramFiles%\Microsoft Visual Studio 9.0\Common7\IDE\ItemTemplates\<Project Type> folder.

为了显示 VS 项目模板,您需要确保在将包含 .vstemplate 和模板代码文件的 .zip 文件复制到 %ProgramFiles%\Microsoft Visual Studio 后运行“devenv.exe /installvstemplates” 9.0\Common7\IDE\ItemTemplates\<项目类型> 文件夹。

I've found that it's useful to wrap the whole thing up into an MSI that discovers the VS9 path, copies the Item/Project template to the necessary folder, and calls a custom action that shells out to devenv.exe passing the "/installvstemplates" switch. That way your colleagues just need to install the package and they are up and running!

我发现将整个内容包装到一个 MSI 中很有用,该 MSI 发现 VS9 路径,将项目/项目模板复制到必要的文件夹,并调用一个自定义操作,该操作会向 devenv.exe 传递“/installvstemplates” “ 转变。这样你的同事只需要安装软件包,他们就可以正常运行了!

Hope this helps.

希望这可以帮助。

回答by Adam Berent

Here are the two articles I found online:

下面是我在网上找到的两篇文章:

First the one on how to create an item template:

第一个关于如何创建项目模板的:

http://msdn.microsoft.com/en-us/library/ms247113(VS.80).aspx

http://msdn.microsoft.com/en-us/library/ms247113(VS.80).aspx

Second is how to get VS to locate the item template.

二是如何让VS定位到item模板。

http://msdn.microsoft.com/en-us/library/y3kkate1(VS.80).aspx

http://msdn.microsoft.com/en-us/library/y3kkate1(VS.80).aspx

As far as I can see you have to place your custom templates in:

据我所知,您必须将自定义模板放在:

My Documents\Visual Studio 2005\Templates\ProjectTemplates\Language\

我的文档\Visual Studio 2005\Templates\ProjectTemplates\Language\

Adam Berent

亚当·贝伦特