Jānis
Jānis

Reputation: 1802

Multi project template references broken

I am building multi project template. One of the child projects is ASP.NET web application. When I export it as a single project template then everything is fine, but when included in multi project template, almost half of references are broken (Antlr3.Runtime, EntitiFramework, Microsoft.Owin and many others)

Multi project template looks like this:

<VSTemplate Version="3.0.0" Type="ProjectGroup" xmlns="http://schemas.microsoft.com/developer/vstemplate/2005">
  <TemplateData>
    <Name>Web Api Solution Template</Name>
    <Description>Template commonly used in projects</Description>
    <ProjectType>CSharp</ProjectType>
    <ProjectSubType>
    </ProjectSubType>
    <SortOrder>1000</SortOrder>
    <CreateNewFolder>true</CreateNewFolder>
    <DefaultName>Web_API</DefaultName>
    <ProvideDefaultName>true</ProvideDefaultName>
    <LocationField>Enabled</LocationField>
    <EnableLocationBrowseButton>true</EnableLocationBrowseButton>
    <Icon>IconSolution.png</Icon>
  </TemplateData>
  <TemplateContent>
    <ProjectCollection>
      <ProjectTemplateLink ProjectName="Api">
        Api\MyTemplate.vstemplate
      </ProjectTemplateLink>
      <ProjectTemplateLink ProjectName="BLL">
        BLL\MyTemplate.vstemplate
      </ProjectTemplateLink>
      <ProjectTemplateLink ProjectName="DBModel">
        DBModel\MyTemplate.vstemplate
      </ProjectTemplateLink>
      <ProjectTemplateLink CopyParameters="true" ProjectName="Web">
        Web\MyTemplate.vstemplate
      </ProjectTemplateLink>
    </ProjectCollection>
  </TemplateContent>
</VSTemplate>

Why is it like that?

Upvotes: 3

Views: 810

Answers (2)

MikeT
MikeT

Reputation: 2663

Use Sidewaffle. When you modify your project(s), no need to update .vstemplates, nugets, any of that. Just rebuild the .vsix project (release), and double click the .vsix in the release folder

Upvotes: 0

Jānis
Jānis

Reputation: 1802

Solved it by using template wizard extension. Basically what I did, was remove all the preinstalled nuget packages from child projects and add them with wizard extension so that the end of project.vstemplate looks like this: (api in this case)

    <WizardExtension>
    <Assembly>NuGet.VisualStudio.Interop, Version=1.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</Assembly>
    <FullClassName>NuGet.VisualStudio.TemplateWizard</FullClassName>
  </WizardExtension>
  <WizardData>
    <packages>
  <package id="EntityFramework" version="6.1.1" targetFramework="net45" />
  <package id="Microsoft.AspNet.Identity.Core" version="2.1.0" targetFramework="net45" />
  <package id="Microsoft.AspNet.Identity.EntityFramework" version="2.1.0" targetFramework="net45" />
  <package id="Microsoft.AspNet.Identity.Owin" version="2.1.0" targetFramework="net45" />
  <package id="Microsoft.AspNet.Cors" version="5.2.3" />
  <package id="Microsoft.AspNet.Mvc" version="5.2.0" targetFramework="net45" />
  <package id="Microsoft.AspNet.Razor" version="3.2.0" targetFramework="net45" />
  <package id="Microsoft.AspNet.Web.Optimization" version="1.1.3" targetFramework="net45" />
  <package id="Microsoft.AspNet.WebApi" version="5.2.0" targetFramework="net45" />
  <package id="Microsoft.AspNet.WebApi.Client" version="5.2.0" targetFramework="net45" />
  <package id="Microsoft.AspNet.WebApi.Core" version="5.2.0" targetFramework="net45" />
  <package id="Microsoft.AspNet.WebApi.HelpPage" version="5.2.0" targetFramework="net45" />
  <package id="Microsoft.AspNet.WebApi.Owin" version="5.2.0" targetFramework="net45" />
  <package id="Microsoft.AspNet.WebApi.WebHost" version="5.2.0" targetFramework="net45" />
  <package id="Microsoft.AspNet.WebPages" version="3.2.0" targetFramework="net45" />
  <package id="Owin" version="1.0" targetFramework="net45" />
  <package id="Microsoft.Owin" version="3.0.1" targetFramework="net45" />
  <package id="Microsoft.Owin.Cors" version="3.0.1" targetFramework="net45" />
  <package id="Microsoft.Owin.Host.SystemWeb" version="2.1.0" targetFramework="net45" />
  <package id="Microsoft.Owin.Security" version="2.1.0" targetFramework="net45" />
  <package id="Microsoft.Owin.Security.Cookies" version="2.1.0" targetFramework="net45" />
  <package id="Microsoft.Owin.Security.Facebook" version="2.1.0" targetFramework="net45" />
  <package id="Microsoft.Owin.Security.Google" version="2.1.0" targetFramework="net45" />
  <package id="Microsoft.Owin.Security.MicrosoftAccount" version="2.1.0" targetFramework="net45" />
  <package id="Microsoft.Owin.Security.OAuth" version="2.1.0" targetFramework="net45" />
  <package id="Microsoft.Owin.Security.Twitter" version="2.1.0" targetFramework="net45" />
  <package id="Microsoft.Web.Infrastructure" version="1.0.0.0" targetFramework="net45" />
  <package id="Newtonsoft.Json" version="6.0.3" targetFramework="net45" />
    </packages>
</WizardData>
</VSTemplate>

As far as I remember, you can copy paste the Assembly part as it won't change in the future.

Upvotes: 2

Related Questions