如何从T4模板访问自定义项目属性? [英] How to access custom project properties from a T4 template?

查看:76
本文介绍了如何从T4模板访问自定义项目属性?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在VS 2010中,是否可以从T4模板访问自定义项目属性,例如在 Assembly 指令中?

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

我无法访问此类属性,例如在.csproj文件的< PropertyGroup> 中定义。虽然可以访问预定义的VS宏(例如 $(SolutionDir) $(ConfigurationName))。

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.

谢谢,最好的问候,
Oliver

Thanks and best regards, Oliver

推荐答案

创建一个包含 Assembly 指令的文件作为预构建步骤(可以访问环境变量)。然后,在我所有的T4模板中,都可以包含此自动生成的文件,该文件将加载程序集。

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.

这篇关于如何从T4模板访问自定义项目属性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆