Concatenate project name to create Template in Visual Studio 2013 c#

Asked

Viewed 139 times

3

I am creating a template for project creation and when editing the file . vstemplate 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 to change the name of "Targetfilename" so that it is dynamic according to the name that the user type in the dialog box? would like to make a concatenation "I"+ "$safeprojectname$" + ". Cs"someone can help me?

1 answer

1

Actually I have to use Projectitem as follows:

<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>

at this point he will be accessing the query folder, if I want to use a name kind of "default" would be something 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="NomeQueEuQUero$fileinputname$OutroNOme.cs" ReplaceParameters="true">ConsultaGrupoProjeto.cs</ProjectItem>
  </TemplateContent>
</VSTemplate>

Browser other questions tagged

You are not signed in. Login or sign up in order to post.