ligershark / side-waffle

A collection of Item- and Project Templates for Visual Studio
Other
657 stars 205 forks source link

Template builder doesnt replace dependecies properly #221

Closed marcusfaoro closed 9 years ago

marcusfaoro commented 9 years ago

Hi there,

Im creating a multi project template project. I followed the instructions in side-waffle website / your videos in youtube but there is something weird.

The project is a Rest Service template which the developer just need to choose a the service name and then all projects are created automatically: BusinessObjects, DataLayer, Common libraries and so on.

Everything was going well, the projects were created fine, the name was replaced by the one chose by the user. However, in some projects the "using" dependencies were not replaced, please check example below:

using System; using NewService.BusinessLogic.Extensions; using NewService.BusinessLogic.Interfaces; using RestSvc.DataAccess.Repository; using RestSvc.DataContracts;

namespace NewService.BusinessLogic { public class CreatePersonOperation : ICreateOperation { private readonly IPersonRepository _personRepository;

    public CreatePersonOperation(IPersonRepository personRepository)
    {
        if (personRepository == null)
            throw new ArgumentNullException("personRepository");

        _personRepository = personRepository;
    }

My MultiProject has as default name "RestSvc". In this example, the user chose to name the service as "NewService". As you can see the RestSvc which belongs to RestSvc.DataAccess and RestSvc.DataContract has been replaced.

Do you have an idea which is causing this?

Im happy to provide source code if needed.

Thanks, Marcus

sayedihashimi commented 9 years ago

Did you go through the wiki https://github.com/ligershark/side-waffle/wiki/How-to-create-a-multi-project-template? That is the most recent and extensive doc.

marcusfaoro commented 9 years ago

Hi Sayed,

Thank you for your reply. Yes, I followed you instruction in the article, however if you follow all the steps described there, a few exceptions are raised regarding: $saferootprojectname$.Specification

Another thing Ive got is you use different VCTemplate version for projects ""

and GroupProject: "<VSTemplate Version="2.0.0" Type="ProjectGroup" xmlns="http://schemas.microsoft.com/developer/vstemplate/2005">"

I dont know if you have interest, my Im happy to share my code.

Thank for your help, Marcus

marcusfaoro commented 9 years ago

Hi Sayed, I dont know if it is a hack, or it supposed to work like that but i fixed doing the following

<VSTemplate Version="3.0.0" xmlns="http://schemas.microsoft.com/developer/vstemplate/2005" Type="Project">
  <TemplateData>
    <Name>Your name here</Name>
    <Description>Project description here</Description>
    <DefaultName>RestSvc.BusinessLogic</DefaultName>

    <ProjectType>CSharp</ProjectType>
    <ProjectSubType></ProjectSubType>
    <SortOrder>1000</SortOrder>
    <CreateNewFolder>true</CreateNewFolder>
    <ProvideDefaultName>true</ProvideDefaultName>
    <LocationField>Enabled</LocationField>
    <EnableLocationBrowseButton>true</EnableLocationBrowseButton>
    <Icon>sw-file-icon.png</Icon>

    <!-- Indicates how many parent folders this item template should appear in -->
    <NumberOfParentCategoriesToRollUp>1</NumberOfParentCategoriesToRollUp>
  </TemplateData>
  <TemplateContent>
    <Project TargetFileName="$projectname$.BusinessLogic.csproj" File="RestSvc.BusinessLogic.csproj" ReplaceParameters="true">
    </Project>
  </TemplateContent>

  <WizardExtension>
    <Assembly>TemplateBuilder, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null</Assembly>
    <FullClassName>TemplateBuilder.ChildWizard</FullClassName>
  </WizardExtension>
</VSTemplate>

_preprocess.xml

<?xml version="1.0" encoding="utf-8" ?>
<Preprocess>
  <!--
  You can specify the path where this should show up in the
  Add New Project / Add New Item dialog by setting the value below
  -->
  <TemplateInfo Path="CSharp\MultiWaffle"/>
  <Replacements Include="*.*" Exclude="*.vstemplate;*.fsproj;*.vbproj;*.jpg;*.png;*.ico;_preprocess.xml;_project.vstemplate.xml">
    <add key="RestSvc.BusinessLogic" value="$safeprojectname$"/>
    <add key="RestSvc.DataContracts" value="$saferootprojectname$.DataContracts"/>
    <add key="RestSvc.DataAccess" value="$saferootprojectname$.DataAccess"/>
    <add key="RestSvc.DataLayer" value="$saferootprojectname$.DataLayer"/>
    <add key="RestSvc.Common" value="$saferootprojectname$.Common"/>
  </Replacements>
</Preprocess>

Thanks,

sayedihashimi commented 9 years ago

That looks right. If the wiki is in need of an update I'd appreciate if you helped out by editing it. I'll close this item now. If there is anything pending please reopen with details.