c# - Getting solution path in a T4 template via MSBuild property -


what best way current solution's full path within t4 template? have is:

<#@ template debug="false" hostspecific="true" language="c#" #> <#@ assembly name="envdte" #> <#@ import namespace="envdte" #> <#@ output extension=".g.cs" #>  <#= "//" + this.dte.solution.filename #>  <#+ private dte dte;  private dte dte {         {         if (this.dte == null)         {             var hostserviceprovider = (iserviceprovider)host;             this.dte = (dte)hostserviceprovider.getservice(typeof(dte));         }          return this.dte;     } } #> 

this works, have concerns:

  • it ties me dte/com layer, have found source of many problems
  • i must have host-specific template, limits future flexibility
  • the documentation solutionclass states various properties infrastructual , microsoft's use only

i hoping find way use msbuild $(solutionpath) property. though it's still vs , won't work if generating within msbuild, @ least cleaner. however, couldn't find way use msbuild property within t4 template control block.

for example, works:

<#@ assembly name="$(projectdir)$(outdir)foo.dll" #> 

but not:

<# writeline("$(projectdir)"); #> 

obviously property needs escaped in manner, couldn't find documentation on how achieve this.


Comments

Popular posts from this blog

cakephp - simple blog with croogo -

How to group boxplot outliers in gnuplot -

bash - Performing variable substitution in a string -