首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >构建工具的选择: MSBuild、NANT还是其他什么?

构建工具的选择: MSBuild、NANT还是其他什么?
EN

Stack Overflow用户
提问于 2016-11-30 14:10:37
回答 3查看 2.5K关注 0票数 8

我正在我的公司做自动化工作。我们是一个C#工作坊。目前,我正在进行自动构建。NANT是流量控制工具。虽然NANT没有积极开发(2012年6月在上发布的最后一个二进制程序和github回购没有激活),但MSBuild更好。因此,我更喜欢MSBuild,但是退休的NANT仍然是有问题的--费用是多少?

我提出了一些利弊,但我知道集体智慧更好。谢谢你的帮忙!

Update:我读过这个问题,但是第二个答案引起了我的担忧。在构建机器上有多个.NET框架,这会很麻烦吗?

MSBuild

Pros

  • 商业支持
  • 社区正在成长
  • 与VS和TFS集成
  • 跟上.Net的步伐

Cons

  • 重写当前脚本
  • 不为人所熟悉

南特

Pros

  • 已在使用
  • 熟悉的人

Cons

  • 很长时间没有更新(自2012年以来)
  • 社区不活跃
  • 缺乏新的.Net支持
EN

回答 3

Stack Overflow用户

回答已采纳

发布于 2018-07-17 17:15:24

谢谢你的回答。我们已经决定使用蛋糕,因为我们是一个C#车间。

票数 2
EN

Stack Overflow用户

发布于 2017-10-16 18:17:02

我们编写了FlubuCore (重写Flubu)。它是一个开放源码的C#库,用于使用C#代码构建项目和执行部署脚本。

我所看到的flubu的主要优点是:

  • .Net核心支持。
  • 易于学习和使用,因为您完全用C#编写构建脚本。
  • 流畅的界面和智慧。
  • 很多内置的任务(编译、运行测试、管理iis、创建部署包、发布nuget包、执行powershell脚本.)
  • 用脚本编写您自己的自定义c#代码并执行它。
  • 使用RunProgramTask在脚本中运行任何外部程序或命令。
  • 引用任何构建脚本中的.net库或c#源代码文件。现在还可以选择在构建脚本中引用nuget包。
  • 编写测试,调试构建脚本。
  • 在任何其他.net应用程序中使用flubu任务。
  • Web可用于flubu。用于远程自动部署。
  • 编写自己的跳槽任务,并与他们扩展流畅的界面。

你可以在纽盖特找到弗劳布:

如果您需要FlubuCore.Runner项目,可以搜索它

搜索dotnet- for.net核心项目(如果你需要它)

在.net中如何使用flubu的示例:

代码语言:javascript
复制
protected override void ConfigureBuildProperties(IBuildPropertiesContext context) {
 context.Properties.Set(BuildProps.NUnitConsolePath,
  @ "packages\NUnit.ConsoleRunner.3.6.0\tools\nunit3-console.exe");
 context.Properties.Set(BuildProps.ProductId, "FlubuExample");
 context.Properties.Set(BuildProps.ProductName, "FlubuExample");
 context.Properties.Set(BuildProps.SolutionFileName, "FlubuExample.sln");
 context.Properties.Set(BuildProps.BuildConfiguration, "Release");
}

protected override void ConfigureTargets(ITaskContext session) {
 var loadSolution = session.CreateTarget("load.solution")
  .SetAsHidden()
  .AddTask(x => x.LoadSolutionTask());

 var updateVersion = session.CreateTarget("update.version")
  .DependsOn(loadSolution)
  .SetAsHidden()
  .Do(TargetFetchBuildVersion);

 session.CreateTarget("generate.commonassinfo")
  .SetDescription("Generates common assembly info")
  .DependsOn(updateVersion)
  .TaskExtensions().GenerateCommonAssemblyInfo()

 var compile = session.CreateTarget("compile")
  .SetDescription("Compiles the solution.")
  .AddTask(x => x.CompileSolutionTask())
  .DependsOn("generate.commonassinfo");

 var unitTest = session.CreateTarget("unit.tests")
  .SetDescription("Runs unit tests")
  .DependsOn(loadSolution)
  .AddTask(x => x.NUnitTaskForNunitV3("FlubuExample.Tests"));

 session.CreateTarget("abc").AddTask(x => x.RunProgramTask(@ "packages\LibZ.Tool\1.2.0\tools\libz.exe"));

 session.CreateTarget("Rebuild")
  .SetDescription("Rebuilds the solution.")
  .SetAsDefault()
  .DependsOn(compile, unitTest);
}

//// Some custom code
public static void TargetFetchBuildVersion(ITaskContext context) {
 var version = context.Tasks().FetchBuildVersionFromFileTask().Execute(context);

 int svnRevisionNumber = 0; //in real scenario you would fetch revision number from subversion.
 int buildNumber = 0; // in real scenario you would fetch build version from build server.
 version = new Version(version.Major, version.Minor, buildNumber, svnRevisionNumber);
 context.Properties.Set(BuildProps.BuildVersion, version);
}

在.net内核中使用flubu的示例

代码语言:javascript
复制
public class MyBuildScript : DefaultBuildScript
{
    protected override void ConfigureBuildProperties(IBuildPropertiesContext context)
    {
        context.Properties.Set(BuildProps.CompanyName, "Flubu");
        context.Properties.Set(BuildProps.CompanyCopyright, "Copyright (C) 2010-2016 Flubu");
        context.Properties.Set(BuildProps.ProductId, "FlubuExample");
        context.Properties.Set(BuildProps.ProductName, "FlubuExample");
        context.Properties.Set(BuildProps.SolutionFileName, "FlubuExample.sln");
        context.Properties.Set(BuildProps.BuildConfiguration, "Release");
    }

    protected override void ConfigureTargets(ITaskContext context)
    {
        var buildVersion = context.CreateTarget("buildVersion")
            .SetAsHidden()
            .SetDescription("Fetches flubu version from FlubuExample.ProjectVersion.txt file.")
            .AddTask(x => x.FetchBuildVersionFromFileTask());

        var compile = context
            .CreateTarget("compile")
            .SetDescription("Compiles the VS solution and sets version to FlubuExample.csproj")
            .AddCoreTask(x => x.UpdateNetCoreVersionTask("FlubuExample/FlubuExample.csproj"))
            .AddCoreTask(x => x.Restore())
            .AddCoreTask(x => x.Build())
            .DependsOn(buildVersion);

        var package = context
            .CreateTarget("Package")
            .CoreTaskExtensions()
            .DotnetPublish("FlubuExample")
            .CreateZipPackageFromProjects("FlubuExample", "netstandard2.0", "FlubuExample")
            .BackToTarget();

    //// Can be used instead of CreateZipPackageFromProject. See MVC_NET4.61 project for full example of PackageTask
    //// context.CreateTarget("Package2").AddTask(x =>   
             x.PackageTask("FlubuExample"));

         var test = context.CreateTarget("test")
            .AddCoreTaskAsync(x => x.Test().Project("FlubuExample.Tests"))
            .AddCoreTaskAsync(x => x.Test().Project("FlubuExample.Tests2"));   

         context.CreateTarget("Rebuild")
             .SetAsDefault()                 
             .DependsOn(compile, test, package);
}

}

详细的演示和文档可以在这里找到:https://github.com/flubu-core/flubu.core

您可以在这里找到完整的示例:https://github.com/flubu-core/examples

票数 6
EN

Stack Overflow用户

发布于 2017-01-11 09:03:16

有一个属性nant.settings.currentframework,用于设置目标框架,以防您有多个.net框架。

代码语言:javascript
复制
<property name="nant.settings.currentframework" value="net-2.0" />

根据.92构建:

  • nant.settings.currentframework当前的目标框架,例如。‘’net 1.0‘。
  • nant.settings.currentframework.description不赞成。当前目标框架的说明。
  • nant.settings.currentframework.frameworkdirectory不赞成。当前目标框架的框架目录。
  • nant.settings.currentframework.sdkdirectory不赞成。当前目标框架的framework目录。
  • nant.settings.currentframework.frameworkassemblydirectory不赞成。当前目标框架的框架程序集目录。
  • nant.settings.currentframework.runtimeengine不赞成。如果使用的话,当前目标框架的运行时引擎。mono.exe。
票数 -1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/40890522

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档