c# – Create item in another project Visual studio 2013 Template

Question:

I'm creating a template in visual studio, but I want that when I add an item to a project, it will be created in all other projects in the solution, can someone help me? the code is more or less this:

<VSTemplate Version="3.0.0" xmlns="http://schemas.microsoft.com/developer/vstemplate/2005" Type="Item">
      <TemplateData>
        <DefaultName>WebApiConsulta.cs</DefaultName>
        <Name>WebApiConsulta</Name>
        <Description>&lt;No description available&gt;</Description>
        <ProjectType>CSharp</ProjectType>
        <SortOrder>10</SortOrder>
        <Icon>__TemplateIcon.png</Icon>
      </TemplateData>
      <TemplateContent>
        <References />
        <ProjectItem SubType="Code" TargetFileName="Projeto1/$fileinputname$.cs" ReplaceParameters="true">ConsultaGrupoProjeto.cs</ProjectItem>
   <ProjectItem SubType="Code" TargetFileName="Projeto2/$fileinputname$.cs" ReplaceParameters="true">ConsultaGrupoProjeto.cs</ProjectItem>
   <ProjectItem SubType="Code" TargetFileName="Projeto3/$fileinputname$.cs" ReplaceParameters="true">ConsultaGrupoProjeto.cs</ProjectItem>
      </TemplateContent>
    </VSTemplate>

Answer:

I don't know if this is exactly what you need, but in the tutorial below the author shows how to create a template for multiple projects, so when you create the solution using the template created, all the projects in the template are already included.

Source: http://www.jayway.com/2015/03/13/visual-studio-how-to-create-a-solution-template-with-multiple-projects/

I hope that's it.

Scroll to Top