c# – how to allow template to rename a file in the project?

0
41

I’ve got a multi-project template:

enter image description here

It makes a call to a child-template in /Schemas:

<VSTemplate Version="3.0.0" xmlns="http://schemas.microsoft.com/developer/vstemplate/2005" Type="Project">
  <TemplateData>
    <Name>FromInterfaceSchemas</Name>
    <Description>&lt;No description available&gt;</Description>
    <ProjectType>CSharp</ProjectType>
    <ProjectSubType>
    </ProjectSubType>
    <SortOrder>1000</SortOrder>
    <CreateNewFolder>true</CreateNewFolder>
    <DefaultName>FromInterfaceSchemas</DefaultName>
    <ProvideDefaultName>true</ProvideDefaultName>
    <LocationField>Enabled</LocationField>
    <EnableLocationBrowseButton>true</EnableLocationBrowseButton>
    <Icon>__TemplateIcon.ico</Icon>
  </TemplateData>
  <TemplateContent>
    <Project TargetFileName="FromFloridaSchemas.btproj" File="FromFloridaSchemas.btproj" ReplaceParameters="true">
      <ProjectItem ReplaceParameters="true" TargetFileName="FromFlorida.xsd">FromFlorida.xsd</ProjectItem>
      <ProjectItem ReplaceParameters="true" TargetFileName="FromFloridaABC.xsd">FromFloridaABC.xsd</ProjectItem>
    </Project>
  </TemplateContent>
</VSTemplate>

Rather than using FromFlorida.xsd, I would like to use a parameter from the parent template such as $projectname$.

I’ve attempting to accomplish this by simply using:

      <ProjectItem ReplaceParameters="true" TargetFileName="$projectname$">FromFlorida.xsd</ProjectItem>

However, this is being ignored.

How do I rename a file that is referenced from the child template?

LEAVE A REPLY

Please enter your comment!
Please enter your name here