CliGenerator 3.0

Posts   
 
    
Posts: 134
Joined: 10-Jan-2007
# Posted on: 29-Jun-2010 00:19:25   

The short version of the CliGenerator does not seem to load the values from the project file. I get a "No templategroup definition of the templategroup '' found."

Taking a look at the source, I do not see anyplace in StartProcess that loads the values. Line 173 loads the project and line 191 does an if !loadValuesFromProjectFile.

Brian

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39614
Joined: 17-Aug-2003
# Posted on: 29-Jun-2010 09:33:36   

At line 189 it obtains the last used values. If it has to use the values specified on the command line, it overwrites them in lines 193-196.

After you've generated code in the designer, you have to save the project to store the last-used values inside the project file. Did you save after you generated code inside the designer?

Frans Bouma | Lead developer LLBLGen Pro
Posts: 134
Joined: 10-Jan-2007
# Posted on: 29-Jun-2010 15:10:52   

I have saved. This is the CodeGenerationCyclePreferences from the project file:


  <CodeGenerationCyclePreferences>
    <OutputType Value="3">
      <LastUsedPreferences>
        <DestinationRootFolder Value="." />
        <FrameworkName Value="LLBLGen Pro Runtime Framework" />
        <LanguageName Value="C#" />
        <PlatformName Value=".NET 3.5" />
        <PresetName Value="SD.Presets.SelfServicing.General2008" />
        <RootNamespace Value="Integrations.Data" />
        <TemplateGroup Value="SelfServicing" />
        <TemplateBindings>
          <Binding Name="Custom template bindings" />
          <Binding Name="SD.TemplateBindings.SharedTemplates.NET35" />
          <Binding Name="SD.TemplateBindings.SqlServerSpecific.NET20" />
          <Binding Name="SD.TemplateBindings.SharedTemplates.NET20" />
          <Binding Name="SD.TemplateBindings.General" />
        </TemplateBindings>
      </LastUsedPreferences>
    </OutputType>
  </CodeGenerationCyclePreferences>

Brian

Posts: 134
Joined: 10-Jan-2007
# Posted on: 29-Jun-2010 16:00:46   

I believe the problem is in line 218:

if(!codeGenMetaData.TemplateGroups.ContainsKey(templateGroupName))

templateGroupName is not ever set to codeGenerationPreferences.TemplateGroup.

Since templateGroupName is used a couple other places, not sure you meant to set and use the codeGenerationPreferences if !loadValuesFromProjectFile OR to set templateGroupName from preferences when loadValuesFromProjectFile

Brian

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39614
Joined: 17-Aug-2003
# Posted on: 29-Jun-2010 16:27:57   

Indeed looks like a bug! We'll fix that. Sorry you ran into this.

Frans Bouma | Lead developer LLBLGen Pro
Posts: 134
Joined: 10-Jan-2007
# Posted on: 29-Jun-2010 16:30:47   

No problem, will just use the long command line for now.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39614
Joined: 17-Aug-2003
# Posted on: 29-Jun-2010 16:57:40   

brianchance wrote:

No problem, will just use the long command line for now.

that works indeed, we use that ourselves for generating test code a lot simple_smile .

Frans Bouma | Lead developer LLBLGen Pro
Posts: 134
Joined: 10-Jan-2007
# Posted on: 29-Jun-2010 17:02:54   

Anyway to tell the generator to use a specific set of Preferences30.xml? It wants to look at the logged in users ApplicationData.

We have a central build box and want to use the CliGenerator now because we can merge the project file.

To complicate that, we run our build scripts as users on different domains (this ensures we have production access before allowing cod to be built and deployed - SOX).

Brian

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39614
Joined: 17-Aug-2003
# Posted on: 29-Jun-2010 17:06:00   

It looks at the local app folder of the user running the app (the 'current user') so if you want to have it look at a given preferences30.xml, you should run the cligenerator under a given user, and place the preferences30.xml in that user's llblgen pro folder in it's own domain folder. Would that work for you?

Frans Bouma | Lead developer LLBLGen Pro
Posts: 134
Joined: 10-Jan-2007
# Posted on: 29-Jun-2010 17:10:34   

We can try, we have 3 users, each with 3 logins. Complicated by the fact we use windows runas with the /noprofile switch.

All of this can be overcome, anyway it could default to one in the LLBLGen Pro v3.0 directory if another is not found?

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39614
Joined: 17-Aug-2003
# Posted on: 30-Jun-2010 10:55:29   

Fixed the issue with the templategroupname, it indeed wasn't set at the right time.

brianchance wrote:

We can try, we have 3 users, each with 3 logins. Complicated by the fact we use windows runas with the /noprofile switch.

All of this can be overcome, anyway it could default to one in the LLBLGen Pro v3.0 directory if another is not found?

If you look at Startup.cs, line 327 and further, the method LoadPreferences(), it uses the special folder of the current environment, 'ApplicationData', which is different for every user, and the value at runtime is the application data folder for the user running the application.

You can either modify that method or run the cligenerator under a special user.

Frans Bouma | Lead developer LLBLGen Pro
Posts: 134
Joined: 10-Jan-2007
# Posted on: 30-Jun-2010 15:05:22   

You can either modify that method or run the cligenerator under a special user

Perfect, I will modify the method.

Brian

Posts: 134
Joined: 10-Jan-2007
# Posted on: 01-Jul-2010 21:51:22   

For anyone interested, I changed the LoadPreferences to look for a CliPreferences30.xml in the CliGenerator directory. If found, it uses it, otherwise falls back to the original logic.


string filePath = Path.Combine(Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location), "Cli" + ApplicationConstants.PreferencesFilename);
if (!File.Exists(filePath))
{
    filePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "LLBLGen Pro");
    if (!Directory.Exists(filePath))
    {
        Directory.CreateDirectory(filePath);
    }
    filePath = Path.Combine(filePath, ApplicationConstants.PreferencesFilename);
}

Brian

MTrinder
User
Posts: 1461
Joined: 08-Oct-2008
# Posted on: 01-Jul-2010 21:59:14   

Thanks for the update, Brian.

Matt