Visual Studio のソリューション エクスプローラーで、プロジェクトの [追加] -> [新しい項目] 右クリック メニューに新しいエントリを追加するテンプレートがあります。
既にテンプレートを作成し、それをドキュメント フォルダーの下の ItemTemplates ディレクトリに配置しました。テンプレートを介してプロジェクトに新しい項目を追加できるという意味で機能します。
ただし、テンプレートは 3 つのファイルで構成されています。
<filename>.controller
<filename>.Designer.cs
<filename>.cs
これらは同じレベルでプロジェクトに追加されますが、プロジェクトにフォームを追加したときに得られるのと同じ種類の階層が必要です.Designer.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>