Concatenate Project Name to Create Template in Visual Studio 2013 c#

Question:

I'm creating a template for project creation and when editing the .vstemplate file I have something like this:

    <VSTemplate Version="3.0.0" xmlns="http://schemas.microsoft.com/developer/vstemplate/2005" Type="Project">
  <TemplateData>
    <Name>Negocio</Name>
    <Description>&lt;No description available&gt;</Description>
    <ProjectType>CSharp</ProjectType>
    <ProjectSubType>
    </ProjectSubType>
    <SortOrder>1000</SortOrder>
    <CreateNewFolder>false</CreateNewFolder>
    <DefaultName>Negocio</DefaultName>
    <ProvideDefaultName>true</ProvideDefaultName>
    <LocationField>Enabled</LocationField>
    <EnableLocationBrowseButton>true</EnableLocationBrowseButton>
    <Icon>__TemplateIcon.jpg</Icon>
  </TemplateData>
  <TemplateContent>
    <Project TargetFileName="SIIM.Negocio.csproj" File="SIIM.Negocio.csproj" ReplaceParameters="false">
      <Folder Name="Base" TargetFolderName="Base">
        <Folder Name="Interface" TargetFolderName="Interface">
          <ProjectItem ReplaceParameters="true" TargetFileName="I'$safeprojectname$'.cs">IPesquisarEstruturaSIIMN.cs</ProjectItem>
        </Folder>
        <ProjectItem ReplaceParameters="true" TargetFileName="'$safeprojectname$'N.cs">PesquisarEstruturaSIIMN.cs</ProjectItem>
      </Folder>
     </Project>
 </TemplateContent>
</VSTemplate>

How can I change the name of "TargetFileName" to be dynamic as the name the user enters in the dialog box? I would like to do an "I"+ "$safeprojectname$" + ".cs" concatenation can someone help me?

Answer:

Actually I have to use ProjectItem like 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="Consulta/$fileinputname$.cs" ReplaceParameters="true">ConsultaGrupoProjeto.cs</ProjectItem>
  </TemplateContent>
</VSTemplate>

in this case it will be accessing the query folder, if I want to use a sort of "default" name it would be something like:

<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="NomeQueEuQUero$fileinputname$OutroNOme.cs" ReplaceParameters="true">ConsultaGrupoProjeto.cs</ProjectItem>
  </TemplateContent>
</VSTemplate>
Scroll to Top