Quantcast
Channel: Visual Studio Integrate forum
Viewing all articles
Browse latest Browse all 4410

T4 - VS Macros no context in TeamBuild

$
0
0

I have a T4 template that processes several .tt files in my project.  I also have some custom classes I've defined to help with the code transformation process.

<#@ template language="C#"  hostspecific="True" debug="True" #><#@ output extension="cs" #><#@ assembly name="System.Core.dll" #><#@ assembly name="$(TargetDir)\MyDependency.dll" #>

This works in Visual Studio, I have a VS Macro which defines $(TargetDir) correctly.

Now, I want to perform the code generation process during my build process.  I added:

<TransformOnBuild>true</TransformOnBuild><OverwriteReadOnlyOutputFiles>true</OverwriteReadOnlyOutputFiles><IncludeDslT4Settings>true</IncludeDslT4Settings>
<ItemGroup><T4ReferencePath Include="$(OutputPath)" /></ItemGroup><Import Project="$(MSBuildExtensionsPath)\Microsoft\VisualStudio\TextTemplating\v10.0\Microsoft.TextTemplating.targets" />

My build runs, but I get:

C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\TextTemplating\v10.0\Microsoft.TextTemplating.targets (407): The host threw an exception while trying to resolve the assembly reference '$(TargetDir)\MyDependency.dll'. The transformation will not be run. The following Exception was thrown: System.IO.FileLoadException: The given assembly name or codebase was invalid. (Exception from HRESULT: 0x80131047)    at System.Reflection.AssemblyName.nInit(RuntimeAssembly& assembly, Boolean forIntrospection, Boolean raiseResolveEvent)    at System.Reflection.AssemblyName.nInit()    at Microsoft.VisualStudio.TextTemplating.GlobalAssemblyCacheHelper.GetLocation(String strongName)    at Microsoft.VisualStudio.TextTemplating.Sdk.Host.GenericTextTemplatingHost.ResolveAssemblyReference(String assemblyReference)    at Microsoft.VisualStudio.TextTemplating.Engine.ResolveAssemblyReferences(ITextTemplatingEngineHost host, TemplateProcessingSession session). Line=-1, Column=-1

Obviously it won't resolve $(TargetDir) in Team build context.

I tried adding TargetDir to my build configuration's property group, to no avail.  This value doens't pass through to the context of the T4 Code Generator.

I don't want to use an environment variable.

How can I set $(TargetDir) correctly in Team Build context?


Viewing all articles
Browse latest Browse all 4410

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>