In my previous post, I showed how you could use a T4 template within Visual Studio to generate a C# ImageLibrary class based on a WPF file called ImageResources.xaml.
If you want to do something similar but the resource file is not in the same folder as the template, you should refer to it using its relative path.
First set the hostspecific attribute to true in the template directive:
<#@ template debug="false" hostspecific="true" language="C#" #>
Then use the code snippet below (in my example, the ImageResources.xaml file is one level up in a folder called Resources) to work out the absolute file path:
string root = Host.ResolvePath(string.Empty);
string relativePath = @"..\Resources\ImageResources.xaml";
string filePath = Path.Combine(root, relativePath);
You can now start reading the file from within your T4 template and extract the information required for auto-generating the code.