问题描述
大家好,
所以我使用Visual Studio 2012和最新的Visualization and Modeling SDK,我想部署我的DSL。
so I am using Visual Studio 2012 and the latest Visualization and Modelling SDK and I want to deploy my DSL.
我尝试了VSIX方式,我只能通过"Project" - >"Add New Item"在现有项目中使用我的DSL创建一个新模型。但我宁愿能够通过"文件" - >"新文件"创建新模型。或者可能是"文件" - >"新的
项目"。我怎样才能实现这一目标?
I tried it the VSIX-way and I can only create a new Model with my DSL in an existing project via "Project"->"Add New Item". But I would rather be able to create a new Model via "File"->"New File" or maybe "File"->"New Project". How can i achieve that?
通过MSI-installer进行部署是为DSL注册文件扩展名和文件图标的唯一方法?
And is the deployment via MSI-installer the only way to register a file extension and file icon for my DSL?
非常感谢。
推荐答案
您只能将DSL添加到现有C#或VB项目的原因是ProjectItem模板仅适用于C#和VB。如果你想知道,请参阅
更多关于这些。
The reason why you can only add your DSL to an existing C# or VB project is that the ProjectItem templates are only available for C# and VB. SeeVSTemplate if you want to know more about these.
您的DslPackage项目包含一个名为ProjectItemTemplates的文件夹,其中包含2个VS模板,用于定义DSL到C#projets的添加新文件(CSharp.vstemplate)和VB项目(VisualBasic.vstemplate)。这2个模板实际上是从2个T4文件(CSharp.tt和VisualBasic.tt)生成
,所以你不应该修改它们。
You DslPackage project contains a folder named ProjectItemTemplates which contains 2 VS templates defining the Add New File for your DSL to C# projets (CSharp.vstemplate), and VB project (VisualBasic.vstemplate). These 2 templates are actually generated from 2 T4 files (CSharp.tt and VisualBasic.tt), so you should not modify them.
如果你想创建你的DSL在不同类型的项目(例如解决方案文件夹)中,只需添加其中一个模板。
If you want your DSL to be create-able in a different kind of project (such as a solution folder), just add one of these templates.
现在,如果你想创建一个新项目,您需要提供ProjectTemplates,例如作为DslPackage的子文件夹。项目模板需要是一个zip文件,将按照这些说明创建"" "
Now if you want to create a new project, you'll need to provide ProjectTemplates, for instance as a sub-folder of the DslPackage. The project Template needs to be a zip file, which will be created following these instructions ""Creating Visual Studio Templates"
我选择添加ProjectTemplates子 - 在DslPackage项目的文件夹中,您还需要将以下行添加到< Content> source.extension.tt的一部分(例如就在关于ItemTemplates的行之后)
I you choose to add the ProjectTemplates sub-folder to the DslPackage project, you will also need to add the following line to the <Content> section of the source.extension.tt (for instance just after the line about ItemTemplates)
< ProjectTemplate> ProjectTemplates< / ProjectTemplate>
<ProjectTemplate>ProjectTemplates</ProjectTemplate>
问候
这篇关于如何:新的DSL模型通过“文件” - >“新文件”?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!