Nested projects in multiproject visual studio templates

我与影子孤独终老i 提交于 2019-12-11 03:47:41

问题


I need to create a vsTemplate with the following structure.

ECart - Ecart.csproject - Modules - Folder - MVC.csproject

How can we add a project within another project? In this case ECart is a web project and MVC is another project within the Modules folder of the same project.

Here is what I am trying in my template -

<ProjectTemplateLink ProjectName="ECart">
    ECart.vstemplate
</ProjectTemplateLink>
<ProjectTemplateLink ProjectName="Mvc">
    Modules\Mvc\Mvc.vstemplate
</ProjectTemplateLink>

回答1:


I did not find a way to do it just by modifying the vstemplate file because the vstemplate's schema was not supporting nested project structure. Hence I found a workaround to do it (not to my liking though). I implemented the IWizard. I zipped the project and added the zip file in the folder structure where I wanted the project to be in. Programatically in the RunFinished method I unzipped the project and added the project into the solution structure.




回答2:


Try using the Solution Folder element as referenced at https://msdn.microsoft.com/en-us/library/ms171399.aspx . Worked for me using the solution tutorial as referenced by jayway at https://blog.jayway.com/2015/03/13/visual-studio-how-to-create-a-solution-template-with-multiple-projects/ .

Example below:

<?xml version="1.0" encoding="utf-8"?>
<VSTemplate Version="2.0.0" Type="ProjectGroup" xmlns="http://schemas.microsoft.com/developer/vstemplate/2005">
  <TemplateData>
    <Name>Quotes</Name>
    <Description>WPF Client with a quote engine</Description>
    <ProjectType>CSharp</ProjectType>
    <Icon>Quotes.ico</Icon>
  </TemplateData>
  <TemplateContent>
    <ProjectCollection>
      <SolutionFolder Name="foo">
        <ProjectTemplateLink>
          QuotesLib\QuotesLib.vstemplate
        </ProjectTemplateLink>
      </SolutionFolder>
      <SolutionFolder Name="bar">
      <ProjectTemplateLink>
        WPFPlay\WPFPlay.vstemplate
      </ProjectTemplateLink>
      </SolutionFolder>
    </ProjectCollection>
  </TemplateContent>
</VSTemplate>


来源:https://stackoverflow.com/questions/29636111/nested-projects-in-multiproject-visual-studio-templates

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