A Silly Question - How do you add a task in V2?

Posts   
 
    
Marcus avatar
Marcus
User
Posts: 747
Joined: 23-Apr-2004
# Posted on: 20-Jul-2006 19:40:42   

Frans,

I'm currently migrating my templates from V1 to V2 and am a little lost regarding how to "add tasks" via the designer.

1) I have copied all my .lpt files to the "C:\Program Files\Solutions Design\LLBLGen Pro v2.0\AdditionalTemplates" folder

2) I have created a new "templatebindings" as follows:

<?xml version="1.0"?>
<templateBindings xmlns="http://sd/llblgen/pro/templateBindingsDefinition.xsd" name="SDS.TemplateBindings.Adapter.NET20"
                  description ="Template bindings for SDS Custom templates" precedenceLevel="10">
  <supportedPlatforms>
    <platform name=".NET 2.0"/>
  </supportedPlatforms>

  <language name="C#">
    <templateBinding templateID="SDS_EntityConcurrencyPredicateFactoryTemplate" filename="sds_EntityConcurrencyPredicateFactoryTemplate.lpt" />
    <templateBinding templateID="SDS_EntityReaderBaseTemplate" filename="sds_EntityReaderBaseTemplate.lpt" />
    <templateBinding templateID="SDS_EntityWriterBaseTemplate" filename="sds_EntityWriterBaseTemplate.lpt" />
    <templateBinding templateID="SDS_EntityPrimaryKeyTemplate" filename="sds_EntityPrimaryKeyTemplate.lpt" />
    <templateBinding templateID="SDS_EntityHelperBaseTemplate" filename="sds_EntityHelperBaseTemplate.lpt" />
  </language>

</templateBindings>

Now Im not sure where the equivelant of the old TaskPerforms .config file goes... or is that something that can be added via the Designer?

Template Bindings are showing up OKAY in the Designer but Add Tasks in the Task Queue only shows existing Tasks... and doesn't let me create new ones...

Do I need to add an additional TaskPerformer file to the AdditionalTemplates folder?

Marcus

Posts: 94
Joined: 26-Feb-2006
# Posted on: 20-Jul-2006 20:22:34   

Frans, it would really be great if you could provide us with a small tutorial concerning creation of custom templates... I am feeling deeply reluctant to start my new templates using codesmith or mygeneration...

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39614
Joined: 17-Aug-2003
# Posted on: 21-Jul-2006 10:37:11   

Marcus wrote:

Frans,

I'm currently migrating my templates from V1 to V2 and am a little lost regarding how to "add tasks" via the designer.

1) I have copied all my .lpt files to the "C:\Program Files\Solutions Design\LLBLGen Pro v2.0\AdditionalTemplates" folder

2) I have created a new "templatebindings" as follows:

<?xml version="1.0"?>
<templateBindings xmlns="http://sd/llblgen/pro/templateBindingsDefinition.xsd" name="SDS.TemplateBindings.Adapter.NET20"
                  description ="Template bindings for SDS Custom templates" precedenceLevel="10">
  <supportedPlatforms>
    <platform name=".NET 2.0"/>
  </supportedPlatforms>

  <language name="C#">
    <templateBinding templateID="SDS_EntityConcurrencyPredicateFactoryTemplate" filename="sds_EntityConcurrencyPredicateFactoryTemplate.lpt" />
    <templateBinding templateID="SDS_EntityReaderBaseTemplate" filename="sds_EntityReaderBaseTemplate.lpt" />
    <templateBinding templateID="SDS_EntityWriterBaseTemplate" filename="sds_EntityWriterBaseTemplate.lpt" />
    <templateBinding templateID="SDS_EntityPrimaryKeyTemplate" filename="sds_EntityPrimaryKeyTemplate.lpt" />
    <templateBinding templateID="SDS_EntityHelperBaseTemplate" filename="sds_EntityHelperBaseTemplate.lpt" />
  </language>

</templateBindings>

Now Im not sure where the equivelant of the old TaskPerforms .config file goes... or is that something that can be added via the Designer?

In v1 you had 1 file: the generator config file. In there you defined the tasks to execute and in which order.

In v2 this is split up: you have .tasks files, which define the tasks you previously defined in the generator config file, and you have .preset files which define WHICH tasks to run, with WHICH parameter values and in WHICH order. simple_smile

the .tasks files you create in an xml editor, if you need to. You don't have to do this, as you can also use the base tasks shipped with LLBLGen Pro and alter the parameter values in the preset. The preset files you create in the generator configuration dialog, at tab 3: you add / remove tasks in the run queue which you can save as a preset for re-use later on.

So, say you had a .lpt template using task in your generator config file for v1. In v2, you simply add the LPT consuming base task to your project somewhere after the tasks which create the folder where the output has to be placed, and you select the task in the run queue after you've added it. Then you can alter the parameters at the bottom in the grid, like which templateid to use, etc.

IF you want to have pre-fab tasks, so you don't have to alter the parameter values, you can create .tasks files and you can place them either in the Tasks folder or in the AdditionalTasks folder specified in the project properties. These pre-fab tasks then show up in the dialog which is popped up when Add Task is clicked at tab 3 in generator configuration dialog and you can then add the task to the run queue. Because all parameters are already pre-set to the right values, you don't have to alter the parameter values.

After you've setup the runqueue with the right tasks, the right parameter values and the tasks in the right order, you can SAVE the preset under a different name, in the Tasks folder or in the folder specified under AdditionalTasks in the project properties so it will show up next time you generate code.

You can also create the presets in an xml editor of course. Use the .xsd files in the XSDs folder in the Tasks folder for intellisense simple_smile

Template Bindings are showing up OKAY in the Designer but Add Tasks in the Task Queue only shows existing Tasks... and doesn't let me create new ones...

Do I need to add an additional TaskPerformer file to the AdditionalTemplates folder? Marcus

In the list of tasks to pick from Add task, you'll find a task (at the top almost) which consumes an lpt template. That's the task you have to add when you want to run an lpt template in your run queue. You then alter the parameters you need to alter, which are the parameters of that task at that spot. So if you add that task again to the runqueue, THAT instance has again the default values.

So the tasks you can add are class definitions and the tasks you see in the run queue are instances simple_smile

Frans Bouma | Lead developer LLBLGen Pro
Otis avatar
Otis
LLBLGen Pro Team
Posts: 39614
Joined: 17-Aug-2003
# Posted on: 21-Jul-2006 10:42:18   

adrianporger wrote:

Frans, it would really be great if you could provide us with a small tutorial concerning creation of custom templates... I am feeling deeply reluctant to start my new templates using codesmith or mygeneration...

Creating templates hasn't changed in v2: the templates work the same way. The thing that has been changed is that the generator config files has been split into 2 files: the task definition files (.tasks) and the task instance files (.preset). So the .tasks files define what parameters a task can have, which task performer it calls etc. In the .preset files (which you create in the generator configuration dialog, tab3) you define which tasks have to be executed in which order and with which parameter values.

The advantage of this is that you can define tasks separately from the run queue (which was previously the generator config file) and you can define multiple presets easily in a gui without having to mess with task definitions in xml.

Frans Bouma | Lead developer LLBLGen Pro
Marcus avatar
Marcus
User
Posts: 747
Joined: 23-Apr-2004
# Posted on: 21-Jul-2006 10:55:13   

Frans... Perfect! This is a whole lot easier than before. WOW

Marcus avatar
Marcus
User
Posts: 747
Joined: 23-Apr-2004
# Posted on: 21-Jul-2006 11:26:06   

If anyone is thinking about migrating a HUGE amount of templates from V1 to V2:

It only takes 30 minutes... This is proof.

I'm very impressed. smile

Marcus

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39614
Joined: 17-Aug-2003
# Posted on: 21-Jul-2006 11:57:42   

Glad you like it and it was as easy to use as intended simple_smile

Frans Bouma | Lead developer LLBLGen Pro