I just finished creating T4 templates to auto-generate property implementations for my ViewModel classes (see here: http://stackoverflow.com/questions/2968406/automatic-inotifypropertychanged-implementation-through-t4-code-generation).
Currently I need to have the project holding the ".tt"-files in the solution where I want to generate the property implementations.
So the solution for example contains three projects: T4Generation, SomeProjectWithViewModels, AnotherProjectWithViewModels.
Then when invoking the T4-template in T4Generation it looks through all of the projects in the solution and finds all of the ViewModel classes and generates a C# file containing property implementations for the specific ViewModel in the respective project.
Example:
"SomeProjectWithViewModels.SomeViewModel.cs"
public partial class SomeViewModel : BaseViewModel
{
private string p_SomeProperty;
}
generates a file "SomeProjectWithViewModels.SomeViewModel.Properties.cs"
public partial class SomeViewModel
{
public string SomeProperty
{
get { ... }
set { ... }
}
}
The question I now have if there is any possibility to create a assembly (ie "T4Generation.dll") that can be referenced in any solution enabling the host solution to invoke the code generation process somehow.
For example I would start a new solution "SomeSolution.sln" with projects "SomeApplication.exe", "SomeClassLibrary.dll" and in SomeApplication I would reference "T4Generation.dll" and during the build process of SomeApplication the T4 generation would be invoked.
Is this possible?