问题描述
我有一个 VS 项目,其中包含:
I have a VS project that contains:
在
template.tt上运行TextTransform以生成generated.cs
generated.cs 列为要编译的文件之一(即在项目文件列表中)
generated.cs listed as one of the files to compile (i.e. in the list of project files)
我在构建项目时,执行了预构建动作,重新创建了generated.cs,但是VS编译的是之前版本的generated.cs(我猜它是在构建过程开始时加载到内存中的).
When I build the project, the pre-build action is executed, generated.cs is re-created, but VS compiles the previous version of generated.cs (which I guess it loaded in memory when the build process started).
如何使构建使用新版本的generated.cs(即在预构建操作中生成的那个)?如何强制构建顺序?
How to make the build use the new version of generated.cs (i.e. the one generated in the pre-build action)? How to force the build order?
请注意,文本转换输入是动态的,因此无法在设计时完成.
推荐答案
这个问题现在有了解决方案!Oleg Sych 在他的博客上发表了一篇文章,详细介绍了如何使构建时转换发挥作用.
There's now a solution to this problem! Oleg Sych has a post on his blog detailing how to make transform-at-build-time work.
这里是来源:https://web.archive.org/web/20140116193428/http://www.olegsych.com/2010/04/understanding-t4-msbuild-integration/
基本上,您只需在项目文件中包含 T4 构建目标并将 TransformOnBuild 属性设置为 true.
Basically, you just include the T4 build targets in your project file and set the TransformOnBuild property to true.
以下是相关摘录:
<Import Project="$(MSBuildToolsPath)Microsoft.CSharp.targets" />
<PropertyGroup>
<TransformOnBuild>true</TransformOnBuild>
</PropertyGroup>
<Import Project="$(MSBuildExtensionsPath)MicrosoftVisualStudioTextTemplatingv10.0Microsoft.TextTemplating.targets" />
请注意,Microsoft.TextTemplating.targets 文件必须包含在 Microsoft.CSharp.targets 之后.
Note that the Microsoft.TextTemplating.targets file has to be included AFTER the Microsoft.CSharp.targets.
这篇关于构建时 T4 转换的产品仅在下一个构建中使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!


大气响应式网络建站服务公司织梦模板
高端大气html5设计公司网站源码
织梦dede网页模板下载素材销售下载站平台(带会员中心带筛选)
财税代理公司注册代理记账网站织梦模板(带手机端)
成人高考自考在职研究生教育机构网站源码(带手机端)
高端HTML5响应式企业集团通用类网站织梦模板(自适应手机端)