带有参数的VSTemplate TargetFolderName

Iva*_*ric 1 c# visual-studio visual-studio-templates

我正在尝试创建类似于MVC的Area的ItemTemplate。无论如何,我无法在TemplateContent中创建一个包含TargetFolderName和参数的文件夹。这是我的TemplateContent部分的简化示例:

<TemplateContent>
    <Folder Name="Area" TargetFolderName="$AreaName$">
        <ProjectItem ReplaceParameters="true" TargetFileName="$AreaName$Controller.cs">Controller.cs</ProjectItem>
    </Folder>
</TemplateContent>
Run Code Online (Sandbox Code Playgroud)

即使MSDN指出TargetFolderName

对于使用参数替换来创建文件夹名称或使用无法在.zip文件中直接使用的国际字符串命名文件夹很有用。

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

输入“ TestArea ”的预期结果:

TestArea
   |__ TestAreaController.cs
Run Code Online (Sandbox Code Playgroud)

实际结果:

$AreaName$
   |__ TestAreaController.cs
Run Code Online (Sandbox Code Playgroud)

有人可以帮忙吗?

提前致谢。

Iva*_*ric 5

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

我可以使用Visual Studio项目模板创建新文件夹吗

所以这就是我解决的方法:

<TemplateContent>
    <ProjectItem ReplaceParameters="true" TargetFileName="$AreaName$\$AreaName$Controller.cs">Controller.cs</ProjectItem>
</TemplateContent>
Run Code Online (Sandbox Code Playgroud)