如何使用Visual Studio项目模板中的变量设置文件名

Gar*_*ary 2 vsx visual-studio-templates vsix visual-studio-extensions

我有一个VS 2013项目模板,其中包含如下项目

<ProjectItem ReplaceParameters="true" TargetFileName="Target.xml">Target.xml</ProjectItem>
Run Code Online (Sandbox Code Playgroud)

我想要的是"Target.xml"是MyProjectName.xml.

我知道我可以在文件中使用变量但不能在名称中使用变量.

谢谢

G

Mat*_*tze 5

实际上,您还可以在项目模板中使用变量.例如...

<ProjectItem 
    TargetFileName="$fileinputname$.xml" 
    ReplaceParameters="true" 
    ItemType="Content">Target.xml</ProjectItem>
Run Code Online (Sandbox Code Playgroud)

...这fileinputname是向导中指定的名称(没有扩展名).该safeprojectname参数将为您提供项目名称(如果这只能与项目模板一起使用,而不是在隔离的项目模板中,则不确定).

这是Project and Item Templates文档的链接; 您可能感兴趣:https://msdn.microsoft.com/en-us/library/ms247121.aspx

可在以下位置找到可用参数列表:https: //msdn.microsoft.com/en-us/library/eehb4faa.aspx