**我是一名正在接受培训的学生,对 C# 的经验很少。
我们公司正在开发一个使用T4模板(C# VS2010)的解决方案。
生成的文件无法在 MSBuild 下编译,因为它依赖于 VS。
我的任务是找到一个工具或库或.dll 文件或SDK 或任何可以在构建时间替代VS 的东西。否则我必须修改生成的代码以使其独立于我自己,我认为这对我来说是一项艰巨的任务。
代码样本:
Project GetProjectContainingT4File(DTE dte) {
// Find the .tt file's ProjectItem
ProjectItem projectItem = dte.Solution.FindProjectItem(Host.TemplateFile);
// If the .tt file is not opened, open it
if (projectItem.Document == null)
projectItem.Open(Constants.vsViewKindCode);
if (AlwaysKeepTemplateDirty) {
// Mark the .tt file as unsaved. This way it will be saved and update itself next time the
// project is built. Basically, it keeps marking itself as unsaved to make the next build work.
// Note: this is certainly hacky, but is the best I could come up with so far.
projectItem.Document.Saved = false;
}
return projectItem.ContainingProject;
}
我将感谢您的帮助。**
限制
生成的文件无法在MSBuild下编译,因为它是VS依赖的
看起来很奇怪。为什么您会以 .NET 环境为目标,但希望您的构建环境独立于 MS?当然,您至少需要一个 C# 编译器。
如果你真的想使用 MSBuild 之外的东西,还有很多替代品,例如 Mono 的微软构建甚至为 Windows 制作.
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)