Bug 727 - Support for VS-style substitutions in T4 include paths
Summary: Support for VS-style substitutions in T4 include paths
Alias: None
Product: Xamarin Studio
Classification: Desktop
Component: T4 ()
Version: 2.6 RC 1
Hardware: PC Windows
: Lowest normal
Target Milestone: ---
Assignee: Mikayla Hutchinson [MSFT]
Depends on:
Reported: 2011-09-10 16:17 UTC by Chris Hardy [MSFT]
Modified: 2013-12-12 15:49 UTC (History)
4 users (show)

Tags: vs
Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.

Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:

Description Chris Hardy [MSFT] 2011-09-10 16:17:58 UTC
T4 can't found include file, but visual studio 2010 did.
F:\UMPWebSolution\UMPWeb.Model\GsmsTyped.tt(5,5): Error: Could not resolve include file '$(ProjectDir)..\UMPWeb.Logic.Mysql\DatabaseHelper.tt'. (UMPWebSolution)
Comment 2 Mikayla Hutchinson [MSFT] 2011-09-10 19:08:29 UTC
The $(ProjectDir) substitution isn't actually a feature of the T4 language, it's specific to Visual Studio. We could support it for compatibility, but that's a bit of a rabbit hole. This particular use isn't really necessary anyway, since the include paths are relative to the file that does the include.
Comment 3 Staffan Einarsson 2013-12-10 11:10:24 UTC
I think a better solution, if one is needed, would be to provide a default MSBuild/xbuild Task for running Mono.TextTemplating. Then you can let MSBuild/xbuild resolve the ProjectDir property before sending it to the TextTemplating engine.
Comment 4 Mikayla Hutchinson [MSFT] 2013-12-10 13:37:01 UTC
@Staffan: that's not really how it works. The T4 engine asks the host (which could be VS, XS, MSBuild tasks, TextTransform.exe, etc) to resolve a path string to an actual path. The VS host chose to implement this by interpreting MSBuild-style substitutions. I could easily implement the same thing in the XS host but I could not guarantee the available substitutions about the the same, which could cause compatibility problems (both ways).
Comment 5 Mikayla Hutchinson [MSFT] 2013-12-12 15:49:23 UTC
This was actually implemented already - https://github.com/mono/monodevelop/commit/7883cde9e11088e1ab2fd042a44e2ed4b64a6cf5