This project is read-only.

Error while generating files outside current project

Apr 9, 2012 at 4:45 PM

First of all thanks for this work, it is very usefull to me as a free alternative to other code generation solutions.

To the point:

I created a project just to host a bunch of T4Toolbox templates, but instead of generating files inside the project, I wanted to generate a complete solution outside current one. The problem with this is that everytime a T4Toolbox templates is disposed, it tries to include the generated file on current project. This produces a COMException at EnvDTE.ProjectItems.AddFromFile(...)

My proposed solution is to add a property: bool IncludeInProject to OutputInfo class, so when method DteProcessor.UpdateOutputFiles is checking outputs, it do not tries to modify current project if the property has value false.

I don't believe the change is too hard to develop, but I might not have the whole picture in mind. Can you suggest me the best path to create the modifications, test it in my local copy (including updating the GAC and the like) so I send you a patch?

Thanks, Iskander

Apr 15, 2012 at 1:27 PM

What type of project are you using?

Apr 15, 2012 at 1:47 PM

I'm using a ClassLibrary to host and run my templates. Actually I uploaded a patch (11940) which I'm using on a local version of the toolbox library and it is working very weel, however I had to add the boolean property IncludeInSolution to OutputInfo, to indicate to all my templates that their output shouldn't be included on it.

Maybe the best solution is to detect whether the output file is outside the current solution, instead of indicating it explicitly with a property, but I made a variant which in case it is not included in the public version, I can apply it whenever a new version of the toolbox is published.