Visual Studio多项目模板重命名名称空间和项目名称 [英] Visual Studio multi-project templates rename namespaces and project names
问题描述
我已经成功创建了一个多项目解决方案模板.但是,我想用解决方案的名称来重命名每个项目的开头.
I've successfully created a multi-project solution template. What I would like to do, however, is to rename the beginning of each project with the name of the solution.
所以我的项目:
- ProjectOne.A
- ProjectTwo.B
将重命名为
- SolutionName.A
- SolutionName.B
其中SolutionName
是用户创建项目时的名称.
where SolutionName
is the name by the user when they created the project.
我已阅读以下文章:
- http://msdn.microsoft.com/en-us/library/ms185308.aspx
- http://msdn.microsoft.com/en-us/library/ms185311.aspx
- http://msdn.microsoft.com/en-us/library/ms247063.aspx
- http://msdn.microsoft.com/en-us/library/ms185308.aspx
- http://msdn.microsoft.com/en-us/library/ms185311.aspx
- http://msdn.microsoft.com/en-us/library/ms247063.aspx
但似乎没有人回答我的具体情况.
but none seem to answer my specific situation.
推荐答案
如果您的主.vstemplate
(解决方案)是下面的示例,
您可以使用向导字典中定义的变量来重命名项目文件夹,然后将.csproj
重命名为所需的任何名称.
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>
对添加的.vstemplates(项目的.vstemplates)进行类似的更改,以重命名.csproj文件.
Use similar changes to addition .vstemplates (the projects' .vstemplates) to rename the .csproj files.
这篇关于Visual Studio多项目模板重命名名称空间和项目名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!