2016-11-30 11 views
5

Tôi đang làm tự động hóa trong công ty của mình. Chúng tôi là một xưởng C#. Hiện tại tôi đang làm việc về xây dựng tự động. NANT là công cụ kiểm soát dòng chảy. Trong khi NANT không được phát triển tích cực (nhị phân cuối cùng được phát hành trên tháng 6 năm 2012 và repo github không hoạt động), MSBuild là tốt hơn. Vì vậy, tôi thích MSBuild nhưng nghỉ hưu NANT vẫn còn nghi ngờ - chi phí là gì?Lựa chọn công cụ xây dựng: MSBuild, NANT hay cái gì khác?

Tôi đã đưa ra một số ưu và nhược điểm, nhưng tôi biết trí thông minh tập thể tốt hơn. Cảm ơn bạn đã giúp đỡ!


Cập nhật: Tôi đã đọc câu hỏi, nhưng câu trả lời thứ hai tăng lên một mối quan tâm đối với tôi. Trên máy xây dựng có nhiều khung công tác .NET, nó có phiền toái không?


MSBuild

Ưu:

  • hỗ trợ thương mại
  • cộng đồng đang phát triển
  • tích hợp với VS và TFS
  • Giữ nhịp với Net

Nhược điểm:

  • kịch bản hiện tại Rewrite
  • Không quen thuộc của người dân

Nant

Ưu:

  • Đã có trong sử dụng
  • quen thuộc của người dân

Nhược điểm:

  • Chưa cập nhật trong một thời gian dài (từ năm 2012)
  • Cộng đồng không hoạt động
  • Thiếu sự hỗ trợ Net mới
+0

Poss ible trùng lặp của [NAnt hoặc MSBuild, cái nào để chọn và khi nào?] (http://stackoverflow.com/questions/476163/nant-or-msbuild-which-one-to-choose-and-when) –

+0

PSake có thể cũng thú vị cho bạn: https://github.com/psake/psake – jessehouwing

+1

Cảm ơn mọi câu trả lời. Chúng tôi đã quyết định sử dụng Bánh vì chúng tôi là một xưởng C#. – DSakura

Trả lời

-1

Có một tài sản nant.settings.currentframework được sử dụng để thiết lập khuôn khổ mục tiêu trong trường hợp bạn có nhiều.khuôn khổ ròng

<property name="nant.settings.currentframework" value="net-2.0" /> 

As per .92 build:

  • nant.settings.currentframework Khung mục tiêu hiện tại, ví dụ. 'net-1.0'.
  • nant.settings.currentframework.descriptionKhông được chấp nhận. Mô tả khung mục tiêu hiện tại.
  • nant.settings.currentframework.frameworkdirectory Không được chấp nhận. Thư mục khung công tác của khung mục tiêu hiện tại.
  • nant.settings.currentframework.sdkdirectoryKhông được chấp nhận. Thư mục SDK khung công tác của khung mục tiêu hiện tại.
  • nant.settings.currentframework.frameworkassemblydirectoryKhông được chấp nhận. Thư mục assembly của khung công tác đích hiện tại.
  • nant.settings.currentframework.runtimeengineKhông được chấp nhận. Động cơ thời gian chạy của khung mục tiêu hiện tại nếu được sử dụng ví dụ. mono.exe.
1

Chúng tôi đã viết FlubuCore (viết lại Flubu). Nó là một thư viện C# nguồn mở để xây dựng các dự án và thực thi các kịch bản triển khai bằng cách sử dụng mã C#.

lợi thế chính của flubu mà tôi nhìn thấy là:

  • hỗ trợ Lõi Net (cũng hoạt động trên Linux và MacOS).
  • Dễ học và sử dụng vì bạn viết hoàn toàn tập lệnh xây dựng trong C#.
  • Khá nhiều công việc được xây dựng (biên dịch, chạy thử nghiệm, quản lý iis, tạo gói triển khai, xuất bản gói nuget, thực thi kịch bản lệnh ...)
  • Viết mã C# tùy chỉnh của riêng bạn và thực thi nó.
  • Chạy bất kỳ chương trình bên ngoài nào trong tập lệnh.
  • Tham chiếu bất kỳ thư viện .net hoặc tệp mã nguồn C# nào trong bản dựng.
  • Giao diện thông thạo và intelisense.
  • Api web khả dụng cho flubu. Hữu ích cho việc triển khai tự động từ xa.
  • Viết các tác vụ flubu của riêng bạn và mở rộng giao diện thông thạo flubu với chúng.

Bạn có thể tìm flubu trên NuGet:

Tìm kiếm FlubuCore.Runner nếu u cần nó cho dự án .net

Tìm kiếm DotNet-flubu nếu u cần nó dự án cốt lõi for.net

Ví dụ về cách sử dụng flubu.net:

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); 
} 

Ví dụ về cách flubu được sử dụng trong lõi .net

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); 
} 

}

Bạn có thể tìm thấy ví dụ đầy đủ ở đây: https://github.com/flubu-core/examples

Wiki có thể được tìm thấy ở đây: https://github.com/flubu-core/flubu.core/wiki

Các vấn đề liên quan