Creating a custom Project File...

Posts   
 
    
Posts: 497
Joined: 08-Apr-2004
# Posted on: 25-Jun-2004 14:02:23   

Hi,

I have a custom "taskperformer" that is based on the Adaptor config - it builds only the GeneratedGeneric project, and I have added some config stuff to create a second project that contains "modified" entities and create a project file for these too. I hope this makes sense!

Anyway, I am struggling with this part of the template for the VS.Net project:

        <Files>
            <Include>
<[FileIncludes]>
            </Include>
        </Files>

The "FileIncludes" should add all the files that are created as part of the generation to the project file, but what it does is add them twice - once for the GeneratedGeneric project, and once for my own project!!

Heres a snippet from the gen'd proj file:

        <File RelPath = "GeneratedGeneric\DatabaseGeneric\EntityClasses\LegislationEntity.cs" BuildAction = "Compile"/>
        <File RelPath = "BusinessEntities\Legislation.cs" BuildAction = "Compile"/>

Any ideas why this is happening?

Posts: 497
Joined: 08-Apr-2004
# Posted on: 25-Jun-2004 14:03:35   

More info:

My config file mod that makes my new project looks like this:

<taskGroup description="Business Entity Objects Creation.">
                <task name="EntitiesDirectoryCreator" assemblyFilename="SD.LLBLGen.Pro.TaskPerformers.dll" taskPerformerClass="SD.LLBLGen.Pro.TaskPerformers.DirectoryCreator">
                    <parameter name="folderToCreate" value="BusinessEntities"/>
                    <parameter name="failWhenExistent" value="false"/>
                    <parameter name="clearWhenExistent" value="false"/>
                </task>
                <task name="EntityClassGenerator" assemblyFilename="SD.LLBLGen.Pro.TaskPerformers.dll" taskPerformerClass="SD.LLBLGen.Pro.TaskPerformers.CodeEmitter">
                    <parameter name="destinationFolder" value="BusinessEntities\"/>
                    <parameter name="failWhenExistent" value="false"/>
                    <parameter name="filenameFormat" value="[elementName].[extension]"/>
                    <parameter name="templateID" value="Entropy_BusinessEntityAdapterTemplate"/>
                    <parameter name="emitType" value="allEntities"/>
                </task>
                <task name="VisualStudio.NetProjectFileCreator" assemblyFilename="SD.LLBLGen.Pro.TaskPerformers.dll" taskPerformerClass="SD.LLBLGen.Pro.TaskPerformers.ProjectFileCreator">
                    <parameter name="destinationFolder" value="BusinessEntities\"/>
                    <parameter name="binRootFolder" value="BusinessEntities\" />
                    <parameter name="alterWhenExistent" value="true"/>
                    <parameter name="filenameFormat" value="BusinessEntities.csproj"/>
                    <parameter name="templateID2002" value="SD_VsNet2002AdapterTemplate"/>
                    <parameter name="templateID2003" value="Entropy_VsNet2003BusinessEntitiesTemplate"/>
                    <parameter name="alwaysTarget" value="2003"/>
                    <parameter name="useRootNameSpaceForProjectName" value="true"/>
                </task>
            </taskGroup>
Otis avatar
Otis
LLBLGen Pro Team
Posts: 39614
Joined: 17-Aug-2003
# Posted on: 25-Jun-2004 14:35:09   

the cache for the filenames isn't cleared. I'll check (not all details are in my head) what to do to clear that cache.

Frans Bouma | Lead developer LLBLGen Pro
Posts: 497
Joined: 08-Apr-2004
# Posted on: 25-Jun-2004 14:36:33   

Thanks simple_smile

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39614
Joined: 17-Aug-2003
# Posted on: 25-Jun-2004 14:44:31   

You have to add this parameter to the vs.net project creation task: <parameter name="clearFileCacheAfterwards" value="true"/>

As the name already suggests: it clears the cache afterwards. If you look closely at the adapter config file, you'll see two tasks for vs.net project file creation, the first has this parameter set to true, so it clears the file name cache so every filename added before that task isn't ending up in the next vs.net project file simple_smile

Frans Bouma | Lead developer LLBLGen Pro
Posts: 497
Joined: 08-Apr-2004
# Posted on: 25-Jun-2004 16:20:36   

Ahhhh

Thanks a lot!

Posts: 497
Joined: 08-Apr-2004
# Posted on: 30-Jun-2004 15:49:18   

Me again!

Its almost there now, but I have one final problem that I can't seem to sort:

I have configured my project file to be in the same folder as my classes (.cs files), but the generated project file adds the folder name to the RelPath when it generates the [FileIncludes] rage

The project taskperformer is:

<taskGroup description="Business Entity Objects Creation.">
            <task name="EntitiesDirectoryCreator" assemblyFilename="SD.LLBLGen.Pro.TaskPerformers.dll" taskPerformerClass="SD.LLBLGen.Pro.TaskPerformers.DirectoryCreator">
                <parameter name="folderToCreate" value="XXX.Envoy.BusinessEntities"/>
                <parameter name="failWhenExistent" value="false"/>
                <parameter name="clearWhenExistent" value="false"/>
            </task>
            <task name="EntityClassGenerator" assemblyFilename="SD.LLBLGen.Pro.TaskPerformers.dll" taskPerformerClass="SD.LLBLGen.Pro.TaskPerformers.CodeEmitter">
                <parameter name="destinationFolder" value="XXX.Envoy.BusinessEntities\"/>
                <parameter name="failWhenExistent" value="false"/>
                <parameter name="filenameFormat" value="[elementName].[extension]"/>
                <parameter name="templateID" value="Entropy_BusinessEntityAdapterTemplate"/>
                <parameter name="emitType" value="allEntities"/>
            </task>
            <task name="VisualStudio.NetProjectFileCreator" assemblyFilename="SD.LLBLGen.Pro.TaskPerformers.dll" taskPerformerClass="SD.LLBLGen.Pro.TaskPerformers.ProjectFileCreator">
                <parameter name="destinationFolder" value="XXX.Envoy.BusinessEntities\"/>
                <parameter name="binRootFolder" value="XXX.Envoy.BusinessEntities\" />
                <parameter name="alterWhenExistent" value="true"/>
                <parameter name="clearFileCacheAfterwards" value="true"/>
                <parameter name="filenameFormat" value="XXX.Envoy.BusinessEntities.csproj"/>
                <parameter name="templateID2002" value="SD_VsNet2002AdapterTemplate"/>
                <parameter name="templateID2003" value="Entropy_VsNet2003BusinessEntitiesTemplate"/>
                <parameter name="alwaysTarget" value="2003"/>
                <parameter name="useRootNameSpaceForProjectName" value="true"/>
            </task>
        </taskGroup>

... and heres a snippet from the gen'd project:

    <Files>
        <Include>
<File RelPath = "XXX.Envoy.BusinessEntities\Legislation.cs" BuildAction = "Compile"/>
        <File RelPath = "XXX.Envoy.BusinessEntities\Legislation_History.cs" BuildAction = "Compile"/>
        <File RelPath = "XXX.Envoy.BusinessEntities\Legislation_MandRep.cs" BuildAction = "Compile"/>
        <File RelPath = "XXX.Envoy.BusinessEntities\Legislation_Priority.cs" BuildAction = "Compile"/>

Any ideas?

Posts: 497
Joined: 08-Apr-2004
# Posted on: 30-Jun-2004 15:56:00   

More info:

I notice that if I change the "EntityClassGenerator" so that the destinationFolder parameter is blank, then the project task performer does not include the folder path in the File Includes.... this is close, but it means the only way I can get it to work as I want it is to generate it directly into the "BusinessEntities" folder....maybe I'm being to fussy?

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39614
Joined: 17-Aug-2003
# Posted on: 30-Jun-2004 18:58:29   

There was a bug in the project file creator before the final 1.0.2004.1 release, where a path without a trailing \ didn't get chopped off ok. Do you use v1.0.2004.1?

Frans Bouma | Lead developer LLBLGen Pro
Posts: 497
Joined: 08-Apr-2004
# Posted on: 01-Jul-2004 10:00:18   

No, its all done on the new release. Maybe I am getting something wrong with the trailing slashes.

The rule that it seems to use is this:

If the class files are gen'd into a folder other than the current folder, then add this folder to the project file when that is generated, **even if **I generate that project file into the same folder.

The rule I expected:

If the class files are gen'd into a folder other than the current folder, then add this folder to the project file when that is generated relative to where the project file is generated (i.e. if I gen the project file into the same place as the class files, no need for extra folder info.)

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39614
Joined: 17-Aug-2003
# Posted on: 01-Jul-2004 18:13:26   

MattWoberts wrote:

No, its all done on the new release. Maybe I am getting something wrong with the trailing slashes.

The rule that it seems to use is this:

If the class files are gen'd into a folder other than the current folder, then add this folder to the project file when that is generated, **even if **I generate that project file into the same folder. The rule I expected:

If the class files are gen'd into a folder other than the current folder, then add this folder to the project file when that is generated relative to where the project file is generated (i.e. if I gen the project file into the same place as the class files, no need for extra folder info.)

It should strip off the generation root folder from the filenames. If you generate in a completely different folder, like c:\blah, the paths are not stripped off.

Frans Bouma | Lead developer LLBLGen Pro
ctadlock avatar
ctadlock
User
Posts: 60
Joined: 12-Feb-2004
# Posted on: 07-Nov-2004 02:36:12   

I just ran into this same issue. It looks like what happens is that when it generates the <include> section of the project file it strips of the generation root folder from the filename. What actually needs to happen is that it needs to strip of the generation root fold AND the project file's destination folder. You dont run into this issue as long as the project file doesnt change relative location to the generated files. The code currently assumes that the project files are at the same folder as the generation root.

An easy way to reproduce this is to change the "destinationFolder" attribute of the project file's task to be "DatabaseGeneric" instead of "" (Adapter). The goal of this is to put the project file inside the "DatabaseGeneric" folder instead of as a peer to it. You'll see that the includes files in the project all have an incorrect "DatabaseGeneric" prefix to them.

Sound correct? I can provide more detail if needed.

(Im using the latest version, 1.0.2004.1.061404)

-CT

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39614
Joined: 17-Aug-2003
# Posted on: 07-Nov-2004 10:25:21   

Well the issue at hand was caused by the destination folder for both projects being the same: destinationRoot\bin\debug and destinationRoot\bin\release. When you build both of then in one solution, the dbspecific project couldn't copy the ormsupportclasses dll to that dir as the dbgeneric project already had and was locking it for some reason. Changing the build destination folder to databasegeneric\bin\debug etc. was the solution. simple_smile

Frans Bouma | Lead developer LLBLGen Pro
ctadlock avatar
ctadlock
User
Posts: 60
Joined: 12-Feb-2004
# Posted on: 07-Nov-2004 19:00:58   

That doesnt seem to be the issue in my case. My two project folders are pointing at completely different folders. Ive been trying all the combinations of settings I can think of to try to get the project file to generate within the "DatabaseGeneric" folder and still have the project file have the correct file includes. Here's the task XML that I think would yield what Im looking for.


<task name="VisualStudio.NetProjectFileCreator" 
 <parameter name="destinationFolder" value="DatabaseGeneric\"/>
 <parameter name="binRootFolder" value="\" />
 <parameter name="alterWhenExistent" value="true"/>
 <parameter name="filenameFormat" value="[projectName].[extension]proj"/>
 <parameter name="templateID2002" value="SD_VsNet2002AdapterTemplate"/>
 <parameter name="templateID2003" value="SD_VsNet2003AdapterTemplate"/>
 <parameter name="alwaysTarget" value="2003"/>
 <parameter name="useRootNameSpaceForProjectName" value="true"/>
</task>

I went and looked at project file generator code in the SDK, it has the code...


for (int i = 0; i < fileNames.Count; i++)
{
    string filename = (string)fileNames[i];
    string buildAction="Compile";
    // chop off destination folder.
    filename = filename.Replace(executingGenerator.ProjectDefinition.DestinationFolder.TrimEnd('\\') + @"\", "");

    // check if the extension of the file is the same as the extension
    if(filename.Substring(filename.Length-3, 3)!=("." + executingGenerator.TemplateSet.FileExtension))
    {
        // not a code file.
        buildAction="None";
    }
    fileIncludes.AppendFormat("\t\t<File RelPath = \"{0}\" BuildAction = \"{1}\"/>{2}", filename, buildAction , Environment.NewLine);
}


To create the filename of the fileInclude it strips off the generator's destinationRoot but doesnt account for the project file's destinationRoot. This works fine in the project file's destinationRoot is "", but not if you've set it to "DatabaseGeneric".

As always, your support for LLBLGen is MUCH appreciated.

-CT

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39614
Joined: 17-Aug-2003
# Posted on: 07-Nov-2004 20:22:27   

Ok, good point. simple_smile I'll add it to the todo to make the projectfile creator do a better job, i.e.: more configurable. (which should be fairly easy, just a couple more parameters simple_smile ).

Frans Bouma | Lead developer LLBLGen Pro
ctadlock avatar
ctadlock
User
Posts: 60
Joined: 12-Feb-2004
# Posted on: 07-Nov-2004 20:42:18   

smile

-CT