[英]Multi project template Visual Studio 2017
I have followed How to create a multi project template in visual studio 2013? 我已经按照如何在visual studio 2013中创建多项目模板? article to create a template. 文章来创建一个模板。 My Project structure is as follows : ProjectName.Domain, ProjectName.Service, ProjectName.UI, ProjectName.sln, root.vstemplate 我的项目结构如下:ProjectName.Domain,ProjectName.Service,ProjectName.UI,ProjectName.sln,root.vstemplate
The root.vstemplate file contains the following: root.vstemplate文件包含以下内容:
Within each sub project there is a ProjectName.vstemplate file, which contains something like this: 在每个子项目中都有一个ProjectName.vstemplate文件,其中包含以下内容:
I have added the *.zip file to /My Documents/Visual Studio 2017/Templates/ProjectTemplates/, but the template does not appear in the New Project Dialog box. 我已将* .zip文件添加到/ My Documents / Visual Studio 2017 / Templates / ProjectTemplates /,但该模板未出现在“新建项目”对话框中。
I had no success either in following the example, which uses Version="2.0.0" for the root vstemplate file. 我没有成功地遵循示例,该示例使用版本=“2.0.0”作为根vstemplate文件。 However, when I followed This article which has en example using Version="3.0.0" it worked. 但是,当我遵循本文时 ,使用Version =“3.0.0”的示例就可以了。
I copied this xml from the article for quick reference: 我从文章中复制了这个xml以供快速参考:
<VSTemplate Version="3.0.0" Type="ProjectGroup" xmlns="http://schemas.microsoft.com/developer/vstemplate/2005">
<TemplateData>
<Name>DevEnvExe Mobile Application Template</Name>
<Description>UWP based Windows mobile application with online and offline feature</Description>
<ProjectType>CSharp</ProjectType>
<ProjectSubType>
</ProjectSubType>
<SortOrder>1000</SortOrder>
<CreateNewFolder>true</CreateNewFolder>
<DefaultName>DevEnv_Template</DefaultName>
<ProvideDefaultName>true</ProvideDefaultName>
<LocationField>Enabled</LocationField>
<EnableLocationBrowseButton>true</EnableLocationBrowseButton>
<Icon>img.png</Icon>
</TemplateData>
<TemplateContent>
<ProjectCollection>
<ProjectTemplateLink ProjectName="$projectname$.Offline">
Dev_Offline\MyTemplate.vstemplate
</ProjectTemplateLink>
<ProjectTemplateLink ProjectName="$projectname$.Online">
DevEnv_Online\MyTemplate.vstemplate
</ProjectTemplateLink>
<ProjectTemplateLink ProjectName="$projectname$.Service">
DevEnv_Service\MyTemplate.vstemplate
</ProjectTemplateLink>
<ProjectTemplateLink ProjectName="$projectname$">
DevEnv_Template\MyTemplate.vstemplate
</ProjectTemplateLink>
</ProjectCollection>
</TemplateContent>
</VSTemplate>
You can use the tool available here: 您可以使用此处提供的工具:
https://github.com/taori/Amusoft.VisualStudio.TemplateGenerator https://github.com/taori/Amusoft.VisualStudio.TemplateGenerator
and use the desktop client or the commandline tool using 并使用桌面客户端或命令行工具
build configuration [configurationName]
after setting up a configuration in the desktop client like this: 在桌面客户端中设置配置后,如下所示:
That way you can regularly update your template with little effort. 这样您就可以轻松地定期更新模板。
run devenv.exe with the /installvstemplates switch. 使用/ installvstemplates开关运行devenv.exe。 This will force Visual Studio to update the project and item templates. 这将强制Visual Studio更新项目和项模板。
eg 例如
"%ProgramFiles(x86)%\Microsoft Visual Studio\2017\Community\Common7\IDE\devenv.exe" /installvstemplates
or where-ever you have installed your Visual Studio. 或者在哪里安装了Visual Studio。 I recommend adding your zip to one of the folders within the ProjectTemplates though, otherwise you'd make a mess of your project dialog box. 我建议您将zip添加到ProjectTemplates中的一个文件夹中,否则您将弄乱项目对话框。
If you would want to use something like this in a bat file, here's a quick example of how to easily do that 如果你想在bat文件中使用这样的东西,这里有一个如何轻松做到这一点的简单例子
set VSDir=C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE
echo Updating templates...
START "" /B /W "%VSDir%\devenv.exe" /installvstemplates
echo All done!
pause
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.