Generating files in different folders and projects

Mar 26, 2009 at 8:14 PM
Oleg,

Something for you to clarify:

  • I wanted a file to be generated on the root of my project (same project the template exists) - not included under the template
  • I created the following template:
  • public class LINQGenerator : Generator{
      protected override void RunCore(){
        LINQTemplate templ = new LINQTemplate();
        templ.Output.File = @"LINQClasses.cs";
        templ.Output.Project = @"LINQClassLibrary.csproj";
        templ.Render();
      }
    }
  • The file was created under my template. If I wanted to have it generated under the template, I could use templ.RenderToFile();
  • I changed the template:
  • public class LINQGenerator : Generator{
      protected override void RunCore(){
        LINQTemplate templ = new LINQTemplate();
        templ.Output.File = @"LINQClasses.cs";
        templ.Output.Project = @"..\LINQClassLibrary\LINQClassLibrary.csproj";
        templ.Render();
      }
    }
  • The file is still generated under my template!

Shouldn't templ.Render() and templ.RenderToFile() make the difference where would the output created?


George J.
 

Coordinator
Mar 27, 2009 at 3:16 AM
Edited Mar 27, 2009 at 3:19 AM
Good catch, George. In this scenario I would also expect the output to be generated under project because Output.Project was assined explicitly.

I see RenderToFile as just a shortcut to setting Output.File and calling Render and would like to avoid attaching additional semantics to it, such as making meaning of Output.File conditional depending on which Render method was called. Having said that, I'll admit that I didn't think of this approach, so let me think about it.