How to access custom project properties from a T4 template?

此生再无相见时 提交于 2019-12-24 17:21:58

问题


In VS 2010, is it possible to access a custom project property from a T4 template, e.g. in an Assembly directive?

I can't manage to access such properties, e.g. defined in a <PropertyGroup> in my .csproj file. Accessing predefined VS macros (like $(SolutionDir) or $(ConfigurationName)) works though.

Thanks and best regards, Oliver


回答1:


I solved the problem by creating a file containing the Assembly directive as a pre-build step (which can access the environment variables). In all my T4 templates I can then include this auto-generated file which loads the assembly.




回答2:


Sure you can have the msbuild file set an environment variable which can then be pulled in via T4.

Also Use MSBuild Properties in T4 Templates there's a command-line way to do it.



来源:https://stackoverflow.com/questions/17696057/how-to-access-custom-project-properties-from-a-t4-template

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!