如何使用 Visual Studio 项目模板中的变量设置文件名 [英] How can I set a file name using a variable in a Visual Studio project template

查看:37
本文介绍了如何使用 Visual Studio 项目模板中的变量设置文件名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I have a VS 2013 project template with a item like below

<ProjectItem ReplaceParameters="true" TargetFileName="Target.xml">Target.xml</ProjectItem>

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

What I want is "Target.xml" to be MyProjectName.xml.

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

I know I can use variables inside the file but not in the name.

谢谢

G

推荐答案

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

Indeed, you can also use variables within the item template. For instance...

<ProjectItem 
    TargetFileName="$fileinputname$.xml" 
    ReplaceParameters="true" 
    ItemType="Content">Target.xml</ProjectItem>

...其中 fileinputname 是向导中指定的名称(不带扩展名).safeprojectname 参数将为您提供项目名称(不确定,如果这只能与项目模板结合使用,而不是在独立项目模板中使用).

...whereby fileinputname is the name as specified in the wizard (without extension). The safeprojectname parameter would give you the project name (not sure, if this can only be used in conjunction with a project template, rather than in an isolated item template).

这是项目和项目模板文档的链接;您可能感兴趣:https://msdn.microsoft.com/en-我们/图书馆/ms247121.aspx

This is the link to the Project and Item Templates documentation; might be of your interest: https://msdn.microsoft.com/en-us/library/ms247121.aspx

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

A list of available parameters can be found at: https://msdn.microsoft.com/en-us/library/eehb4faa.aspx

这篇关于如何使用 Visual Studio 项目模板中的变量设置文件名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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