我有一个 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模板网!
是否有执行 Excel NORMINV 函数的 C# 库?Is there a C# library that will perform the Excel NORMINV function?(是否有执行 Excel NORMINV 函数的 C# 库?)
从 C# 中的加权列表中选择 x 个随机元素(无需替换Select x random elements from a weighted list in C# (without replacement)(从 C# 中的加权列表中选择 x 个随机元素(无需替换))
给定轮班列表,创建时间表的摘要描述Create a summary description of a schedule given a list of shifts(给定轮班列表,创建时间表的摘要描述)
C# 普通随机数C# Normal Random Number(C# 普通随机数)
通用列表的标准偏差?Standard deviation of generic list?(通用列表的标准偏差?)
AsyncCTP:创建一个 IAwaitable 的类AsyncCTP: Creating a class that is IAwaitable(AsyncCTP:创建一个 IAwaitable 的类)