c# - How do you get T4ReferencePath to work? -


i've beat head against wall couple of days on one. no amount of googling or messing around seems yield answer.

i want run t4 template @ build time. in it, need access types in assembly i've built before project. need msbuild able build it, , msbuild doesn't play nice vs variables, need use means load assembly.

i've read in lot of places t4referencepath answer setting place load custom assembly from. however, cannot work.

when specify this:

<t4referencepath include="$(targetdir)" /> 

i when either try load project in vs or run msbuild:

d:\users\250894\documents\visual studio 2013\projects\testt4\testt4.csproj(90,22): error msb4066: attribute "include" in element <t4referencepath> unrecognized. 

i have "visual studio visualization , modeling sdk" installed.

i apologize lack of brevity, i'm including entire .csproj file of test project in case glaringly obvious i've missed. i'm not including .tt file because isn't relevant if can't csproj load. if exclude t4referencepath, things work correctly.

<?xml version="1.0" encoding="utf-8"?> <project toolsversion="12.0" defaulttargets="build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">   <import project="$(msbuildextensionspath)\$(msbuildtoolsversion)\microsoft.common.props" condition="exists('$(msbuildextensionspath)\$(msbuildtoolsversion)\microsoft.common.props')" />   <propertygroup>     <configuration condition=" '$(configuration)' == '' ">debug</configuration>     <platform condition=" '$(platform)' == '' ">anycpu</platform>     <projectguid>{5b9944e7-47cf-4bfe-baef-f02d29d59e80}</projectguid>     <outputtype>exe</outputtype>     <appdesignerfolder>properties</appdesignerfolder>     <rootnamespace>testt4</rootnamespace>     <assemblyname>testt4</assemblyname>     <targetframeworkversion>v4.5</targetframeworkversion>     <filealignment>512</filealignment>   </propertygroup>   <propertygroup condition=" '$(configuration)|$(platform)' == 'debug|anycpu' ">     <platformtarget>anycpu</platformtarget>     <debugsymbols>true</debugsymbols>     <debugtype>full</debugtype>     <optimize>false</optimize>     <outputpath>bin\debug\</outputpath>     <defineconstants>debug;trace</defineconstants>     <errorreport>prompt</errorreport>     <warninglevel>4</warninglevel>   </propertygroup>   <propertygroup condition=" '$(configuration)|$(platform)' == 'release|anycpu' ">     <platformtarget>anycpu</platformtarget>     <debugtype>pdbonly</debugtype>     <optimize>true</optimize>     <outputpath>bin\release\</outputpath>     <defineconstants>trace</defineconstants>     <errorreport>prompt</errorreport>     <warninglevel>4</warninglevel>   </propertygroup>   <propertygroup condition="'$(configuration)|$(platform)' == 'debug|x64'">     <debugsymbols>true</debugsymbols>     <outputpath>bin\x64\debug\</outputpath>     <defineconstants>debug;trace</defineconstants>     <debugtype>full</debugtype>     <platformtarget>x64</platformtarget>     <errorreport>prompt</errorreport>     <codeanalysisruleset>minimumrecommendedrules.ruleset</codeanalysisruleset>     <prefer32bit>true</prefer32bit>   </propertygroup>   <propertygroup condition="'$(configuration)|$(platform)' == 'release|x64'">     <outputpath>bin\x64\release\</outputpath>     <defineconstants>trace</defineconstants>     <optimize>true</optimize>     <debugtype>pdbonly</debugtype>     <platformtarget>x64</platformtarget>     <errorreport>prompt</errorreport>     <codeanalysisruleset>minimumrecommendedrules.ruleset</codeanalysisruleset>     <prefer32bit>true</prefer32bit>   </propertygroup>   <itemgroup>     <reference include="system" />     <reference include="system.core" />     <reference include="system.xml.linq" />     <reference include="system.data.datasetextensions" />     <reference include="microsoft.csharp" />     <reference include="system.data" />     <reference include="system.xml" />   </itemgroup>   <itemgroup>     <compile include="program.cs" />     <compile include="properties\assemblyinfo.cs" />     <compile include="test.cs">       <autogen>true</autogen>       <designtime>true</designtime>       <dependentupon>test.tt</dependentupon>     </compile>   </itemgroup>   <itemgroup>     <none include="app.config" />     <none include="test.tt">       <generator>texttemplatingfilegenerator</generator>       <lastgenoutput>test.cs</lastgenoutput>     </none>   </itemgroup>   <itemgroup>     <service include="{508349b6-6b84-4df5-91f0-309beebad82d}" />   </itemgroup>   <import project="$(msbuildtoolspath)\microsoft.csharp.targets" />   <propertygroup>     <!-- visual studio version – defaults 12: -->     <visualstudioversion condition="'$(visualstudioversion)' == ''">12.0</visualstudioversion>     <!-- keep next element on 1 line: -->     <vstoolspath condition="'$(vstoolspath)' == ''">$(msbuildextensionspath32)\microsoft\visualstudio\v$(visualstudioversion)</vstoolspath>     <transformonbuild>true</transformonbuild>     <includedslt4settings>true</includedslt4settings>     <t4referencepath include="$(targetdir)" />   </propertygroup>   <import project="$(vstoolspath)\texttemplating\microsoft.texttemplating.targets" /> </project> 

i stumbled onto answer. can't imagine no 1 has run before, here are. hopefully, i've blazed trail come after.

in spite of common sense tells me, t4referencepath not "property". it's "item". when removed "propertygroup" , added "itemgroup", got happy.

one of blights of software development , computer use in general unhelpful error messages. can't egregious example i've ever encountered, it's there.


Comments

Popular posts from this blog

database - VFP Grid + SQL server 2008 - grid not showing correctly -

jquery - Set jPicker field to empty value -

.htaccess - htaccess convert request to clean url and add slash at the end of the url -