T4-VS宏在TeamBuild中没有上下文 [英] T4 - VS Macros no context in TeamBuild

查看:58
本文介绍了T4-VS宏在TeamBuild中没有上下文的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个T4模板,可以处理项目中的多个.tt文件.我还定义了一些自定义类,以帮助进行代码转换过程.

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" #>

这在Visual Studio中有效,我有一个VS宏,可以正确定义$(TargetDir).

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):主机在尝试解析程序集引用'$(TargetDir)时引发了异常\ MyDependency.dll".转型不会 跑步.引发了以下异常:System.IO.FileLoadException:给定的程序集名称或代码库无效. (来自HRESULT的异常:0x80131047)在System.Reflection.AssemblyName.nInit(RuntimeAssembly&程序集,布尔值用于自省, 布尔值raiseResolveEvent)   在System.Reflection.AssemblyName.nInit()处在Microsoft.VisualStudio.TextTemplating.GlobalAssemblyCacheHelper.GetLocation(String strongName)在Microsoft.VisualStudio.TextTemplating.Sdk.Host.GenericTextTemplatingHost.ResolveAssemblyReference(String assemblyReference)   在Microsoft.VisualStudio.TextTemplating.Engine.ResolveAssemblyReferences(ITextTemplatingEngineHost主机,TemplateProcessingSession会话)处. Line = -1,Column = -1

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

很明显,它不会在团队构建上下文中解析$(TargetDir).

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

我尝试将TargetDir添加到构建配置的属性组中,但无济于事.此值不会传递到T4代码生成器的上下文中.

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.

我不想使用环境变量.

如何在Team Build上下文中正确设置$(TargetDir)?

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

推荐答案

嗨加文,

我们知道,我们可以使用

As we know, we can use 


(variableName)语法来引用Visual Studio或MSBuild变量.我发现您可以在Visual Studio中很好地工作.
(variableName) syntax to reference Visual Studio or MSBuild variables. And I found you could work it well in Visual Studio.

对于团队建设,我并不熟悉.

To Team Build, I am not familiar with it.

我正在尝试让熟悉此主题的人参与进来,以进一步研究该问题.可能会有一些时间延迟.感谢您的耐心.
 
感谢您的理解和支持.

I am trying to involve someone familiar with this topic to further look at this issue. There might be some time delay. Appreciate your patience.
 
Thank you for your understanding and support.

最好的问候


这篇关于T4-VS宏在TeamBuild中没有上下文的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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