我有一个模板,它在 Visual Studio 的解决方案资源管理器中的项目上的“添加->新项目”右键单击菜单中添加了一个新条目。
我已经构建了模板,将其放入我的文档文件夹下的 ItemTemplates 目录中,并且它可以工作,因为我可以通过模板将新项目添加到项目中。
但是,模板包含 3 个文件:
<filename>.controller
<filename>.Designer.cs
<filename>.cs
这些被添加到同一级别的项目中,但我希望在向项目中添加表单时获得相同类型的层次结构,其中 .Designer.cs 文件作为子节点放置在.cs 文件。
基本上,这就是项目的样子:
TestProject
+- Properties
+- References
+- App.config
+- Program.cs
+- MyTestController.controller
+- MyTestController.Designer.cs
+- MyTestController.cs
而我希望它看起来像这样:
TestProject
+- Properties
+- References
+- App.config
+- Program.cs
+- MyTestController.controller
+- MyTestController.Designer.cs
+- MyTestController.cs
这可能吗?如果是这样,我应该在我的 .vstemplate 文件中更改什么来获得这种行为?
这是我添加到模板 zip 文件中的 .vstemplate 文件:
<VSTemplate Version="2.0.0" Type="Item" xmlns="http://schemas.microsoft.com/developer/vstemplate/2005">
<TemplateData>
<Name>LVK.NET New Controller</Name>
<Description>Adds an business logic controller class to the project.</Description>
<Icon Package="{FAE04EC1-301F-11d3-BF4B-00C04F79EFBC}" ID="4522" />
<ProjectType>CSharp</ProjectType>
<SortOrder>10</SortOrder>
<DefaultName>Controller.controller</DefaultName>
</TemplateData>
<TemplateContent>
<References>
<Reference>
<Assembly>System</Assembly>
</Reference>
<Reference>
<Assembly>System.Data</Assembly>
</Reference>
<Reference>
<Assembly>System.Xml</Assembly>:\
</Reference>
<Reference>
<Assembly>LVK.Core</Assembly>
</Reference>
<Reference>
<Assembly>LVK.BusinessLogic</Assembly>
</Reference>
</References>
<ProjectItem ReplaceParameters="true">Controller.controller</ProjectItem>
<ProjectItem ReplaceParameters="true" TargetFileName="$fileinputname$.Designer.cs">Controller.Designer.cs</ProjectItem>
<ProjectItem ReplaceParameters="true" TargetFileName="$fileinputname$.cs">Controller.cs</ProjectItem>
</TemplateContent>
</VSTemplate>