手动创建的项目模板无法正确替换参数 [英] Manually Created Item Template Not replacing parameters correctly

查看:79
本文介绍了手动创建的项目模板无法正确替换参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


香港专业教育学院得到了我创建的项目模板,该模板用于创建自定义可视化Web部件.

.vstemplate定义如下

 <   VSTemplate    版本  ="    类型  =" 项目" 
          xmlns   ="  http://schemas.microsoft.com/developer/vstemplate/2005" <   TemplateData  > 
    <  名称 > 窗口小部件模板<  /Name  > 
    <  图标 >  Icon.ico <  /Icon  > 
    <  说明 >  HFEA小部件模板<  /说明 > 
    <   ProjectType  >  CSharp <  /ProjectType  > 
    <   DefaultName  >  wpWebpart <  /DefaultName  > 
  <  /TemplateData  > 
  <   TemplateContent  > 
    <   ProjectItem     ="   true"  TargetFileName    $ fileinputname $ \ $ fileinputname $ .cs" <  /ProjectItem  > 
    <   ProjectItem     ="   true"  TargetFileName    $ fileinputname $ \ $ fileinputname $ .webpart" <  /ProjectItem  > 
    <   ProjectItem     ="   true"  TargetFileName    $ fileinputname $ \ $ fileinputname $ UserControl.ascx" <  /ProjectItem  > 
    <   ProjectItem     ="   true"  TargetFileName    $ fileinputname $ \ $ fileinputname $ UserControl.ascx.cs" <  /ProjectItem  > 
    <   ProjectItem     ="   true"  TargetFileName    $ fileinputname $ \ $ fileinputname $ UserControl.ascx.designer.cs" <  /ProjectItem  > 
    <   ProjectItem     ="   true"  TargetFileName    $ fileinputname $ \ SharePointProjectItem.spdata"  > 
      SharePointProjectItem.spdata
    <  /ProjectItem  > 
    <   ProjectItem     ="   true"  TargetFileName    $ fileinputname $ \ Elements.xml"  > 
      Elements.xml
    <  /ProjectItem  > 
  <  /TemplateContent  > 
<  /VSTemplate  >  



对于几乎所有文件来说,它都可以正常工作,而ReplaceParameters可以完美地放入正确的名称和名称空间等.

但针对以下内容:-

 <   ProjectItem     ReplaceParameters   ="     TargetFileName   ="  > 
  SharePointProjectItem.spdata
<  /ProjectItem  > 
<   ProjectItem     ="   true"  TargetFileName    $ fileinputname $ \ Elements.xml"  > 
  Elements.xml
<  /ProjectItem  >   



它不起作用.

基本上,它的意思是进入每个文件,并用添加新项目"对话框中指定的项目名称替换一些标签.

似乎会忽略添加新项"中指定的名称,而只是使用文件名

下面是Elements.xml的示例.

 <?  xml    版本  ="    编码  ="  utf-8" > 
<  元素    ="   http://schemas.microsoft.com/sharepoint/"   > 
  <  模块    ="   $ safeitemrootname $" 列表   113 " 网址   _ catalogs/wp" <  文件    ="   $ safeitemrootname $ \ $ safeitemrootname $ .webpart"   网址  ="    类型   GhostableInLibrary"  > 
      <  属性    ="   Group"   自定义"   / > 
    <  /File  > 
  <  /Module  > 
<  /Elements  >   




它应该做的是将$ safeitemrootname $替换为添加新项"对话框中指定的名称.

而是将$ safeitemrootname $替换为名称"Elements".

如果我使用
,似乎是因为我没有重命名文件 TargetFileName ="$ fileinputname $ \ $ fileinputname $ .Elements.xml

它工作正常,但随后我必须在项目中将其重命名为Elements.xml.

有没有人遇到过这个问题,或者知道需要添加什么才能使其正常工作.

解决方案

fileinputname


\


文件输入名称


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

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

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

解决方案

fileinputname


\


fileinputname


这篇关于手动创建的项目模板无法正确替换参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆