Visual Studio multi-project templates rename namespaces and project names

纵饮孤独 提交于 2019-12-03 03:35:46
Danny Varod

If your main .vstemplate (the solution's one) is like the example below, you can use variables defined in wizard's dictionary to rename project folders and .csproj to whatever names you want.

<?xml version="1.0" encoding="utf-8"?>
<VSTemplate Version="2.0.0" Type="ProjectGroup"
xmlns="http://schemas.microsoft.com/developer/vstemplate/2005">
    <TemplateData>
        <Name>My Web Server Solution with DAL</Name>
        <Description>Creates Projects for Web Server DAL and adds them to a new or existing solution</Description>
        <Icon></Icon>
        <ProjectType>CSharp</ProjectType>
        <ProjectSubType>My</ProjectSubType>
        <DefaultName>WebServer</DefaultName>
        <NumberOfParentCategoriesToRollUp>2</NumberOfParentCategoriesToRollUp>
        <TemplateGroupID>My</TemplateGroupID>
        <TemplateID>My.Dal.Web.Template</TemplateID>
    </TemplateData>
    <TemplateContent>
        <ProjectCollection>
            <ProjectTemplateLink ProjectName="$ModelProjectName$">
                Children\Model\ProjectTemplate.vstemplate
            </ProjectTemplateLink>
            <ProjectTemplateLink ProjectName="$SharedModelContractsProjectName$">
                Children\SharedModelContracts\ProjectTemplate.vstemplate
            </ProjectTemplateLink>
            <ProjectTemplateLink ProjectName="$RepositoryInterfacesProjectName$">
                Children\RepositoryInterfaces\ProjectTemplate.vstemplate
            </ProjectTemplateLink>
            <ProjectTemplateLink ProjectName="$RepositoryImplementationProjectName$">
                Children\RepositoryImplementation\ProjectTemplate.vstemplate
            </ProjectTemplateLink>
            <ProjectTemplateLink ProjectName="$RepositoryExtensionsProjectName$">
                Children\RepositoryExtensions\ProjectTemplate.vstemplate
            </ProjectTemplateLink>
        </ProjectCollection>
    </TemplateContent>
    <WizardExtension>
        <Assembly>My.WebServerDalExtension.Wizard, Version=1.0.0.0, Culture=neutral, PublicKeyToken=5c93c79b0feae916</Assembly>
        <FullClassName>My.WebServerDalExtension.Wizard.Controller</FullClassName>
    </WizardExtension>
</VSTemplate>

Use similar changes to addition .vstemplates (the projects' .vstemplates) to rename the .csproj files.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!