سؤال

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

هل كانت مفيدة؟

المحلول

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.

نصائح أخرى

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.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top