这有什么错我的Visual Studio 2008的模板? [英] What's wrong with my Visual Studio 2008 template?

查看:175
本文介绍了这有什么错我的Visual Studio 2008的模板?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图创建Visual Studio中被称为公共课堂我自己的类模板

I'm trying to create my own class template for Visual Studio called "Public Class".

我跟着的官方MSDN上如何手动创建相当多的信,但我有没有运气得到一个项模板的说明该模板显示在添加新项对话框

I followed the official MSDN instructions on how to manually create an Item Template pretty much to the letter, but I'm having no luck getting the template to show up in the "My Templates" section of the "Add New Item" dialog.

我把PublicClass.zip在下列Windows XP目录中的我的模板部分:

I placed PublicClass.zip in the following Windows XP directory:

C:\Documents和Settings\My用户Name\My Documents\Visual工作室2008\Templates\ItemTemplates\Visual C#

C:\Documents and Settings\My User Name\My Documents\Visual Studio 2008\Templates\ItemTemplates\Visual C#.

公开Class.zip包含以下文件:


  1. PublicClass。 CS

  2. PublicClass.ico

  3. PublicClass.vstemplate

PublicClass.cs包含...

using System;
using System.Collections.Generic;
$if$ ($targetframeworkversion$ == 3.5)using System.Linq;
$endif$using System.Text;

namespace Pse.$projectname$
{
    public class $safeitemname$
    {
    }
}

PublicClass.vstemplate包含...

<?xml version="1.0" encoding="utf-8"?>
<VSTemplate
  Type="Item"
  Version="1.0.0"
  xmlns="http://schemas.microsoft.com/developer/vstemplate/2005">
  <TemplateData>
    <Name>Public Class</Name>
    <Description>An empty class declaration with access modifier = public and namespace = Pse.NameOfProject</Description>
    <Icon>PublicClass.ico</Icon>
    <ProjectType>CSharp</ProjectType>
    <DefaultName>PublicClass.cs</DefaultName>
  </TemplateData>
  <TemplateContent>
    <ProjectItem ReplaceParameters="true">PublicClass.cs</ProjectItem>
  </TemplateContent>
</VSTemplate>



我开始了工作室,尝试新的项目添加到我的项目,但我的模板是无处被发现。所以,我也跟着这个计算器问题 ,这是调用...

I started up Studio, tried to add a new item to my project, but my template was nowhere to be found. So, I followed the advice of this stackoverflow question, which was to call...

devenv.exe /installvstemplates

......在命令行中,但所有的所做的就是让所有的模板(包括内置的)消失。恐慌片刻之后,我最终得到了他们回来运行命令几次之后,却清楚地不是为我的答案。

...from the command line, but all that did was make all the templates (including the built-in ones) disappear. After a few moments of panic, I eventually got them back after running the command several times, but that clearly wasn't the answer for me.

如果你看到任何错误在这里我的过程中,你能帮我吗?

If you see anything wrong with my procedure here, can you please help me out?

在此先感谢。

修改

如果我使用的文件/导出模板(如普里特建议),模板的确实在我的模板的展现出来, ,但参数不更换正确

If I use File/Export Template (as suggested by Preet), the template does show up in My Templates, but the parameters are not replacing properly.

如果我插入一个新的公班,这是我得到:

If I insert a new "Public Class", this is what I get:

using System;
using System.Collections.Generic;
$if$ (3.5 == 3.5)using System.Linq;
$endif$using System.Text;

namespace Pse.$projectname$
{
    public class PublicClass1
    {
    }
}

因此,只有 $项目名称$ $ targetframeworkversion $ 正确更换。它不处理 $如果$ 语句或 $项目名称$ 正常。 (我也用试过 $ safeprojectname $ ,但是这并没有区别。)

So, only $projectname$ and $targetframeworkversion$ are replacing properly. It's not handling the $if$ statement or $projectname$ properly. (I also tried using $safeprojectname$, but that made no difference.)

这绝对是其中之一其中,试图让我的生活更方便一点的情况下曾经有过完全相反的效果:)

This is definitely one of those cases where trying to make my life a little more convenient had had exactly the opposite effect :)

推荐答案

我有这个问题:)

和我想我设法解决它,我在做非常类似我真正想要的是有一个标准的模板,曾在标题为我们的SVN系统最后我的东西抽取富现有Class.zip文件:\Program Files\Microsoft的Visual Studio 9.0\Common7\IDE\ItemTemplates\CSharp\Code\1033,然后编辑它,我结束了与此

And I think I managed to solve it I was doing something very similar what I really wanted was to have a standard template which had headers in for our svn system I ended up extracting the existing Class.zip file in Foo:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\ItemTemplates\CSharp\Code\1033 and then editing it I ended up with this

// $Id$
// $Author$
namespace $rootnamespace$
{
    using System;
    using System.Collections.Generic;
$if$ ($targetframeworkversion$ == 3.5)  using System.Linq;
$endif$    using System.Text;

    public class $safeitemrootname$
    {
    }
}

有关的间距$如果$说法似乎有所作为。如果我有标签或之前间隔,他们将无法正常或者说他们没有评估因为你所看到的,但被简单地印在我的代码评估

The spacing for the $if$ statement did seem to make a difference If I had tabs or spaced before them they would not evaluate properly or rather they did evaluate as you are seeing but were simply printed in my code.

至于你的模板消失,当你运行/ installvstemplates,以及什么情况是,你可能会注意到CMD需要相当长一段时间的运行,它是什么INFACT做的是删除
的Foo:\Program Files\Microsoft的Visual Studio 9.0\Common7\IDE\ItemTemplatesCache,然后通过上述提取的原始位置的zip文件重建该文件夹。对于这个命令的行为Visual Studio是最好关机,而你运行它,你应该等到命令完成重新启动它。 (提示我用实际监测的文件夹,看着它建)。

As for your templates disappearing when you run /installvstemplates, well whats happening is you may notice that cmd takes quite a while to run, what it is infact doing is deleting Foo:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\ItemTemplatesCache and then rebuilding that folder by extracting the zip files in the original locations as mentioned above. For this command to behave visual studio is best shutdown whilst you run it and you should wait until the command has finished to restart it. (tip I used to actually monitor the folder and watch it build).

个人allthough这是一个灵活的系统微软真的会犯这样的用户更容易,毕竟R·有这样一个简单的右键功能,如果你有R·这是落实MS系统外模板的最简单的方法。

Personally allthough this is a flexible system microsoft really could have made this easier for the user, after all R# has this as a simple right click feature, if you have R# this is the easiest way to implement templates outside of the ms system.

这篇关于这有什么错我的Visual Studio 2008的模板?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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