CodeSmith Community
Your Code. Your Way. Faster!

Preserving custom references during regeneration

Latest post 07-16-2007 9:54 AM by zainuddin. 8 replies.
  • 09-16-2006 4:07 AM

    • manudea
    • Top 500 Contributor
    • Joined on 09-11-2006
    • Posts 19
    • Points 575

    Preserving custom references during regeneration

    Hi,

    I have added some code to the code generated by templates. My code requires some external references. Every time I regenrate the references are overwritten so I have to rebind dll each time. Is there a way to preserve them or just add somewhere so that I have not to fix manually?

    Thanks

    Manu

    • Post Points: 95
  • 09-18-2006 1:37 PM In reply to

    • shotolab
    • Top 500 Contributor
    • Joined on 04-20-2006
    • Posts 18
    • Points 360

    Re: Preserving custom references during regeneration

    My team had the same issue.  We have modified the templates to include our refefences so that we don't have to update the projects manually.

    That was our best solution.  I would like to hear other's solution.

    Brian
    • Post Points: 35
  • 10-25-2006 10:20 AM In reply to

    • heckubus
    • Top 75 Contributor
    • Joined on 06-27-2006
    • Posts 54
    • Points 1,165

    Re: Preserving custom references during regeneration

    In my project I use NAnt to automate the entire regeneration and build process.  I've gone down the route of customizing the NetTiers templates, but that only works until you decide you need the latest and greatest version from SVN.  Unless you don't mind continually merging your custom changes with the latest version.

    What I did instead, was use a perl script and Regex expressions to parse the generated .csproj files and add in the project references, after they are generated, and before they are compiled.  It was a lot of work initially, but worth it now.

    -Casey
     

    • Post Points: 5
  • 02-26-2007 2:08 PM In reply to

    Re: Preserving custom references during regeneration

    If you are using C# with Visual Studio 2005, I would think it simplest just to use partial classes in any templates that need future modification.  Make sure your output is always ClassName.Generated.CS, and that your class declaration in the template is partial.  Then just add another file declared with the same partial class name, and put your customized code / references / events / etc... in there.

    I hope this is helpful.

    Eric.

    • Post Points: 35
  • 02-27-2007 4:08 AM In reply to

    • swin
    • Top 10 Contributor
    • Joined on 06-14-2006
    • London, UK
    • Posts 922
    • Points 34,710

    Re: Preserving custom references during regeneration

    I think the original problem is to do with Project references rather than class references.  The point is that if you include an external reference in your project it will get wiped out the next time you regenerate because .netTiers recreates the .csproj file everytime. 

    A non hacky way of preserving these references would certainly be a good idea, but I'm not sure how easy this would be to implement. 

    swin 

    ------------------------------------------------- Member of the .NetTiers team -------------------------------------------------
    • Post Points: 35
  • 06-17-2007 12:09 PM In reply to

    Re: Preserving custom references during regeneration

    Has anyone found an elegant solution to this? I'm tired of resetting references after I regen. I often get latest from the SVN repository as well, and would like to stay away from modifying the templates. I sort of like the idea of using regex to parse and insert the references after regen and before compile, but I don't want to spend the time writing all of that if someone else has some sample code that does the same thing. Ideas?

     

    -T 

    • Post Points: 35
  • 06-18-2007 2:30 AM In reply to

    • swin
    • Top 10 Contributor
    • Joined on 06-14-2006
    • London, UK
    • Posts 922
    • Points 34,710

    Re: Preserving custom references during regeneration

    One way I get round this is by having a layer on top of the netTiers layers where I do any extra business logic that is outside of the scope of netTeirs - this includes anything that requires other references.  Not ideal but it saves you getting the problem you have.

    hth

    swin 

    ------------------------------------------------- Member of the .NetTiers team -------------------------------------------------
    • Post Points: 35
  • 06-18-2007 10:07 AM In reply to

    Re: Preserving custom references during regeneration

    Interesting solution. I do something similar (mediator pattern) already with parts of the netTiers framework. I'll try moving more into it and see if it cuts my regen time down. I use the processors in the netTiers service layer extensively, so I may have to do some shuffling, but would be worth it if it makes regen easier.

     

    Thanks for the tip!

    -Tony 

    • Post Points: 5
  • 07-16-2007 9:54 AM In reply to

    • zainuddin
    • Not Ranked
    • Joined on 03-27-2007
    • Posts 8
    • Points 160

    Re: Preserving custom references during regeneration

    Hi There,

    It will be great if anyone can give an example of how to modify the templates to include new references.

    I want to include Microsoft.logging.exception library  to web.proj.

    Thanks for your kind help.

    Regards,

    Z

    zainuddin
    • Post Points: 5
Page 1 of 1 (9 items) | RSS
Copyright © 2008 CodeSmith Tools, LLC
Powered by Community Server (Commercial Edition), by Telligent Systems