c# - 带有参数的 VSTemplate TargetFolderName

标签 c# visual-studio visual-studio-templates

我正在尝试创建类似于 MVC 区域的 ItemTemplate。无论如何,我无法在 TemplateContent 中创建一个 Folder,它将有一个带参数的 TargetFolderName。这是我的 TemplateContent 部分的简化示例:

<TemplateContent>
    <Folder Name="Area" TargetFolderName="$AreaName$">
        <ProjectItem ReplaceParameters="true" TargetFileName="$AreaName$Controller.cs">Controller.cs</ProjectItem>
    </Folder>
</TemplateContent>

尽管MSDN表示 TargetFolderName

useful for using parameter replacement to create a folder name or naming a folder with an international string that cannot be used directly in the .zip file.

尽管如此,我还是无法完成这项工作。

输入“TestArea”的预期结果:

TestArea
   |__ TestAreaController.cs

实际结果:

$AreaName$
   |__ TestAreaController.cs

有人可以帮忙吗?

提前致谢。

最佳答案

刚刚在这里找到了解决方法:

Can I create a new folder with a Visual Studio Item Template

我就是这样解决的:

<TemplateContent>
    <ProjectItem ReplaceParameters="true" TargetFileName="$AreaName$\$AreaName$Controller.cs">Controller.cs</ProjectItem>
</TemplateContent>

关于c# - 带有参数的 VSTemplate TargetFolderName,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20284651/

相关文章:

c# - 后台 worker - 使用字符串数组报告进度

c# - 我可以将 PHP 关联数组传递给 ComVisible .NET 函数吗?

c# - 如何在 Visual Studio 中启用/禁用编译错误警告

visual-studio - VS2013 with GitHub - 停止由提交的 typescript 文件制作的 JS 文件

c# - Visual Studio 2012 项目模板自定义参数和重命名问题

c# - 帮助抽象类/类/接口(interface)单元的结构

c# - 有没有办法在 Scala 中使用命名字段的元组,类似于 C# 中的匿名类?

c# - 将来将 Xamarin 添加到 Visual Studio C# 项目

c# - 无法嵌入互操作类型 'ProjectKinds'。改用适用的接口(interface)

visual-studio-2010 - 在项目模板中使用本地 IWizard 程序集作为 WizardExtension