Click here to Skip to main content
15,885,216 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
hi
ive got a item template that i have created, this one is made to create a custom visual web part.

the .vstemplate is defined as follows

XML
<VSTemplate Version="2.0.0" Type="Item"
    xmlns="http://schemas.microsoft.com/developer/vstemplate/2005">
  <TemplateData>
    <Name>Widget Template</Name>
    <Icon>Icon.ico</Icon>
    <Description>HFEA Widget Template</Description>
    <ProjectType>CSharp</ProjectType>
    <DefaultName>wpWebpart</DefaultName>
  </TemplateData>
  <TemplateContent>
    <ProjectItem ReplaceParameters="true" TargetFileName="$fileinputname$\$fileinputname$.cs">
      wpWebPart3_Incidents12Months.cs
    </ProjectItem>
    <ProjectItem ReplaceParameters="true" TargetFileName="$fileinputname$\$fileinputname$.webpart">
      wpWebPart3_Incidents12Months.webpart
    </ProjectItem>
    <ProjectItem ReplaceParameters="true" TargetFileName="$fileinputname$\$fileinputname$UserControl.ascx">
      wpWebPart3_Incidents12MonthsUserControl.ascx
    </ProjectItem>
    <ProjectItem ReplaceParameters="true" TargetFileName="$fileinputname$\$fileinputname$UserControl.ascx.cs">
      wpWebPart3_Incidents12MonthsUserControl.ascx.cs
    </ProjectItem>
    <ProjectItem ReplaceParameters="true" TargetFileName="$fileinputname$\$fileinputname$UserControl.ascx.designer.cs">
      wpWebPart3_Incidents12MonthsUserControl.ascx.designer.cs
    </ProjectItem>
    <ProjectItem ReplaceParameters="true" TargetFileName="$fileinputname$\SharePointProjectItem.spdata">
      SharePointProjectItem.spdata
    </ProjectItem>
    <ProjectItem ReplaceParameters="true" TargetFileName="$fileinputname$\Elements.xml">
      Elements.xml
    </ProjectItem>
  </TemplateContent>
</VSTemplate>


and for nearly all the files it works fine , and the ReplaceParameters works perfectly to put in the correct names and namespaces etc.

but for the following :-
XML
<ProjectItem ReplaceParameters="true" TargetFileName="$fileinputname$\SharePointProjectItem.spdata">
  SharePointProjectItem.spdata
</ProjectItem>
<ProjectItem ReplaceParameters="true" TargetFileName="$fileinputname$\Elements.xml">
  Elements.xml
</ProjectItem>


it doesnt work.

basically its meant to go into each of these files and replace some tags with the item name specified at the "add new item" dialog.

it seems to ignore the name specified in "add new item" and just simply uses the name of the file ,

the example for Elements.xml here is whats inside it.
XML
<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/" >
  <Module Name="$safeitemrootname$" List="113" Url="_catalogs/wp">
    <File Path="$safeitemrootname$\$safeitemrootname$.webpart" Url="$safeitemrootname$.webpart" Type="GhostableInLibrary" >
      <Property Name="Group" Value="Custom" />
    </File>
  </Module>
</Elements>



what it should do is replace $safeitemrootname$ with the name specified in the "add new item" dialog.

but instead it replaces $safeitemrootname$ with the name "Elements" instead.

it seems to be because i am not renaming the file , if i use
TargetFileName="$fileinputname$\$fileinputname$.Elements.xml

it works fine , but then i have to in the project rename it back to Elements.xml.

has anyone come across this , or know what needs to be added to get it to work correctly.
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900