c#-4.0 - 是否有任何 MSBuild 替代方案?

标签 c#-4.0

**我是一名接受培训的学生,对 C# 的经验很少。
我们公司正在开发使用 T4 模板(C# VS2010)的解决方案。
生成的文件不能在 MSBuild 下编译,因为它是 VS 依赖的。
我的任务是找到一个工具或库或 .dll 文件或 SDK 或任何可以在构建时替换 VS 的东西。否则,我必须将生成的代码修改为独立于我自己的 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;

}

我很感激你的帮助。**

最佳答案

限制

The generated files can't be compiled under MSBuild because it is VS dependent



看起来很奇怪。为什么您要以 .NET 环境为目标,但希望您的构建环境独立于 MS?当然,您至少需要一个 C# 编译器。

如果你真的想使用 MSBuild 之外的东西,还有很多替代品,比如 Mono 的 Microsoft.Build甚至 Make for Windows .

关于c#-4.0 - 是否有任何 MSBuild 替代方案?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11582250/

相关文章:

c#-4.0 - 使用 Exchange 服务器和 C# 删除收件箱邮件项目

c# - VB.NET下的Late Binding Magic转换为C#

c#-4.0 - 为什么在启动我的服务时会出现完成消息?

c#-4.0 - MVC 自定义错误页面可以保留路由值吗?

c# - 如何在 C# 中将 Base64 PNG 图像字符串转换为 PNG 格式

asp.net-mvc - 如何在 Razor 中获得选定的单选按钮

c#-4.0 - ASP.NET MVC 用户具有所有角色

c#-4.0 - 如何在我们的dll中使用dotfuscator

c# - 使用 ToDictionary 创建字典

asp.net - 在 asp.net 中动态添加多个系列到图表