从 VS 项目模板中的默认名称中删除数字

Remove number from default name in VS item template

当我在 VisualStudio 中转到 "Add New Item" 并选择我的自定义项目模板(以及默认项目模板)时,名称的默认条目是 XY1.cs,始终具有 1 最后,虽然 vstemplate 文件中没有给出 1

据我所知,如果同名元素已经存在,VS 会增加这个数字。

但为什么它以 1 开头并且没有被排除?我可以阻止 VS 在我的自定义模板中添加 1 吗?我想在我的模板中为给定名称添加一个额外的字符串,但通常用户不会删除 1 或者只是监督它,所以它会导致 {WantedFilename}1{AdditionalString}

根据 Visual Studio IDE 团队高级项目经理 Mark Wilson-Thomas 的说法 MSDN Blog

Creating through the File-New Item dialog adds a “1” To the filename If you use the File-New Item dialog route to create your EditorConfig, in Visual Studio versions prior to 15.8 Preview 4, you’ll need to manually remove the superfluous “1” Prefixing the EditorConfig file name in the dialog. This is fixed in the 15.8 Preview 4 release.

更新

此公告似乎仅适用于 .editorconfig 个文件(以及 .manifest 等其他一些文件)

有关详细信息,请参阅