Reputation: 176
I'm using T4 to transform an h file from our embedded library into a C# file. This works fine, but I would like to provide relative reference to the file in question. So far this is all I've been able to come up with:
s = Path.GetDirectoryName(Host.ResolvePath("thisFile.tt")) + @"\..\foo\bar.h";
It would be nice if I could include bar.h in the project and change the build action to "None" and then simplify:
s = Host.ResolvePath("bar.h");
But this throws an error and as far as I can tell you can only ResolvePath for files in the same directory as the T4 script.
Anyone have a better way?
Upvotes: 1
Views: 1510
Reputation: 1423
Since bar.h is in a different folder, you need to give it the relative path. So you would do
s = Host.ResolvePath(@"..\foo\bar.h");
The answer can be found at https://msdn.microsoft.com/en-us/library/gg604090(v=vs.100).aspx
To find the full path of a file relative to the text template, use this.Host.ResolvePath().
Upvotes: 1