最好的 .NET 构建工具

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/16550/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-03 09:39:06  来源:igfitidea点击:

Best .NET build tool

.netbuild-processnant

提问by alanl

Possible Duplicate:
NAnt or MSBuild, which one to choose and when?

可能的重复项:
NAnt 或 MSBuild,选择哪一个,何时选择?

What is the best build tool for .NET?

.NET的最佳构建工具是什么?

I currently use NAntbut only because I have experience with Ant. Is MSBuildpreferred?

我目前使用NAnt但只是因为我有使用Ant 的经验。MSBuild是首选吗?

采纳答案by Peter Meyer

We actually use a combination of NAntand MSBuildwith CruiseControl. NAnt is used for script flow control and calls MSBuild to compile projects. After the physical build is triggered, NAnt is used to publish the individual project build outputs to a shared location.

我们实际上将NAntMSBuildCruiseControl结合使用。NAnt 用于脚本流控制,调用 MSBuild 编译项目。触发物理构建后,NAnt 用于将单个项目构建输出发布到共享位置。

I am not sure this is the bestprocess. I think many of us are still looking for a great build tool. One promising thing I heard recently on .NET Rocks, episode 362, is James Kovac's PSake, a build system he based entirely on PowerShell. It sounds really promising since what you can do with PowerShell is fairly limitless in theory.

我不确定这是最好的过程。我认为我们中的许多人仍在寻找一款出色的构建工具。我最近在 .NET Rocks第 362 集听到的一个很有希望的事情是James Kovac 的 PSake,他完全基于 PowerShell 构建系统。这听起来很有希望,因为理论上你可以用 PowerShell 做的事情是无限的。

回答by Jamie

I'd just like to throw FinalBuilderin to the mix. It's not free, but if you're fed up with editing XMLfiles and want a somewhat nicer (IMO) environment to work in I would give it a go.

我只想将FinalBuilder加入其中。它不是免费的,但是如果您厌倦了编辑XML文件并且想要一个更好的 ( IMO) 环境,我会尝试一下。

I've worked with all of them and have always went back to FinalBuilder.

我和他们所有人一起工作过,并且总是回到 FinalBuilder。

回答by Lee

I use MSBuild completely for building. Here's my generic MSBuild script that searches the tree for .csproj files and builds them:

我完全使用 MSBuild 进行构建。这是我的通用 MSBuild 脚本,它在树中搜索 .csproj 文件并构建它们:

<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003" DefaultTargets="Build">
  <UsingTask AssemblyFile="$(MSBuildProjectDirectory)\bin\xUnit\xunitext.runner.msbuild.dll" TaskName="XunitExt.Runner.MSBuild.xunit"/>
  <PropertyGroup>
    <Configuration Condition="'$(Configuration)'==''">Debug</Configuration>
    <DeployDir>$(MSBuildProjectDirectory)\Build$(Configuration)</DeployDir>
    <ProjectMask>$(MSBuildProjectDirectory)\**\*.csproj</ProjectMask>
    <ProjectExcludeMask></ProjectExcludeMask>
    <TestAssembliesIncludeMask>$(DeployDir)\*.Test.dll</TestAssembliesIncludeMask>
  </PropertyGroup>

  <ItemGroup>
    <ProjectFiles Include="$(ProjectMask)" Exclude="$(ProjectExcludeMask)"/>
  </ItemGroup>

  <Target Name="Build" DependsOnTargets="__Compile;__Deploy;__Test"/>

  <Target Name="Clean">
    <MSBuild Projects="@(ProjectFiles)" Targets="Clean"/>
    <RemoveDir Directories="$(DeployDir)"/>
  </Target>

  <Target Name="Rebuild" DependsOnTargets="Clean;Build"/>

  <!--
  ===== Targets that are meant for use only by MSBuild =====
  -->
  <Target Name="__Compile">
    <MSBuild Projects="@(ProjectFiles)" Targets="Build">
      <Output TaskParameter="TargetOutputs" ItemName="AssembliesBuilt"/>
    </MSBuild>
    <CreateItem Include="@(AssembliesBuilt -> '%(RootDir)%(Directory)*')">
      <Output TaskParameter="Include" ItemName="DeployFiles"/>
    </CreateItem>
  </Target>

  <Target Name="__Deploy">
    <MakeDir Directories="$(DeployDir)"/>
    <Copy SourceFiles="@(DeployFiles)" DestinationFolder="$(DeployDir)"/>
    <CreateItem Include="$(TestAssembliesIncludeMask)">
      <Output TaskParameter="Include" ItemName="TestAssemblies"/>
    </CreateItem>
  </Target>

  <Target Name="__Test">
    <xunit Assembly="@(TestAssemblies)"/>
  </Target>
</Project>

(Sorry if it's a little dense. Markdown seems to be stripping out the blank lines.)

(对不起,如果它有点密集。Markdown 似乎正在去除空白行。)

It's pretty simple though once you understand the concepts and all the dependencies are handled automatically. I should note that we use Visual Studio project files, which have a lot of logic built into them, but this system allows people to build almost identically both within the Visual Studio IDE or at the command line and still gives you the flexibility of adding things to the canonical build like the xUnit testing you see in the script above.

虽然一旦您理解了概念并且所有依赖项都会自动处理,这非常简单。我应该注意到,我们使用 Visual Studio 项目文件,其中内置了很多逻辑,但是该系统允许人们在 Visual Studio IDE 或命令行中几乎完全相同地构建,并且仍然为您提供添加内容的灵活性到规范构建,如您在上面的脚本中看到的 xUnit 测试。

The one PropertyGroup is where all the configuration happens and things can be customized, like excluding certain projects from the build or adding new test assembly masks.

一个 PropertyGroup 是所有配置发生的地方,并且可以自定义事物,例如从构建中排除某些项目或添加新的测试程序集掩码。

The ItemGroup is where the logic happens that finds all the .csproj files in the tree.

ItemGroup 是在树中查找所有 .csproj 文件的逻辑发生的地方。

Then there are the targets, which most people familiar with make, nAnt or MSBuild should be able to follow. If you call the Build target, it calls __Compile, __Deploy and __Test. The Clean target calls MSBuild on all the project files for them to clean up their directories and then the global deployment directory is deleted. Rebuild calls Clean and then Build.

然后是大多数熟悉 make、nAnt 或 MSBuild 的人应该能够遵循的目标。如果您调用 Build 目标,它会调用 __Compile、__Deploy 和 __Test。Clean 目标在所有项目文件上调用 MSBuild 以清理它们的目录,然后删除全局部署目录。Rebuild 调用 Clean,然后调用 Build。

回答by netbuild

There is another new build tool (a very intelligent wrapper) called NUBuild. It's lightweight, open source and extremely easy to setup and provides almost no-touch maintenance. I really like this new tool, and we have made it a standard tool for our continuous build and integration of our projects (we have about 400 projects across 75 developers). Try it out.

还有另一个名为NUBuild 的新构建工具(一个非常智能的包装器)。它是轻量级的、开源的并且非常容易设置并且提供几乎无接触的维护。我真的很喜欢这个新工具,我们已经将它作为我们持续构建和集成项目的标准工具(我们在 75 个开发人员中有大约 400 个项目)。试试看。

http://nubuild.codeplex.com/

http://nubuild.codeplex.com/

  • Easy to use command line interface
  • Ability to target all .NETFramework versions, that is, 1.1, 2.0, 3.0 and 3.5
  • Supports XML based configuration
  • Supports both project and file references
  • Automatically generates the “complete ordered build list” for a given project – No touch maintenance.
  • Ability to detect and display circular dependencies
  • Perform parallel build - automatically decides which of the projects in the generated build list can be built independently.
  • Ability to handle proxy assemblies
  • Provides a visual clue to the build process, for example, showing “% completed”, “current status”, etc.
  • Generates detailed execution log both in XML and text format
  • Easily integrated with CruiseControl.NETcontinuous integration system
  • Can use custom logger like XMLLogger when targeting 2.0 + version
  • Ability to parse error logs
  • Ability to deploy built assemblies to user specified location
  • Ability to synchronize source code with source-control system
  • Version management capability
  • 易于使用的命令行界面
  • 能够面向所有.NETFramework 版本,即 1.1、2.0、3.0 和 3.5
  • 支持基于 XML 的配置
  • 支持项目和文件引用
  • 自动生成给定项目的“完整有序构建列表”——无需接触维护。
  • 能够检测和显示循环依赖
  • 执行并行构建 - 自动决定生成的构建列表中的哪些项目可以独立构建。
  • 处理代理程序集的能力
  • 提供构建过程的视觉线索,例如,显示“完成百分比”、“当前状态”等。
  • 以 XML 和文本格式生成详细的执行日志
  • CruiseControl.NET持续集成系统轻松集成
  • 面向 2.0 + 版本时可以使用自定义记录器,如 XMLLogger
  • 能够解析错误日志
  • 能够将构建的程序集部署到用户指定的位置
  • 能够将源代码与源代码控制系统同步
  • 版本管理能力

回答by liammclennan

Rakeand Albacore is an excellent combination. The power of Ruby and no XML.

Rake和 Albacore 是一个很好的组合。Ruby 的强大功能,而不是 XML。

.NET Open Source 5 - .NET Automation with Rake and Albacore by Liam McLennan[Tekpub.com]

.NET 开源 5 - Liam McLennan[Tekpub.com]使用 Rake 和 Albacore 的 .NET 自动化

回答by Tim Macfarlane

We're using Bounce, a framework for cleaner build scripts in C#.

我们正在使用Bounce,这是一个在 C# 中更清晰的构建脚本的框架。

回答by Graviton

I use a commercial software, Automated Build Studiofor the build purpose.

我使用商业软件Automated Build Studio进行构建。

回答by Greg Hurlman

We use MSBuild, because we started with Visual Studio 2005 (now Visual Studio 2008), and MSBuild was already "built in" to the SDK - there is less maintenance on the build server. It's a NAnt clone, really - both tools are infinitely flexible in that they let you create custom build tasks in code, and both have a decent set of community build tasks already created.

我们使用 MSBuild,因为我们从 Visual Studio 2005(现在是 Visual Studio 2008)开始,并且 MSBuild 已经“内置”到 SDK 中 - 生成服务器上的维护较少。这是一个 NAnt 克隆,真的 - 这两种工具都非常灵活,因为它们允许您在代码中创建自定义构建任务,并且都已经创建了一组不错的社区构建任务。

回答by Riri

It also depends on whatyou're building. The MSBuild SDC Task libraryhas a couple of special tasks. For example, for AD, BizTalk, etc.

这也取决于什么你正在构建。该MSBuild的SDC任务库中有几个特殊的任务。例如,对于ADBizTalk等。

There are over 300 tasks included in this library including tasks for: creating websites, creating application pools, creating ActiveDirectory users, running FxCop, configuring virtual servers, creating zip files, configuring COM+, creating folder shares, installing into the GAC, configuring SQL Server, configuring BizTalk 2004 and BizTalk 2006, etc.

该库中包含 300 多个任务,包括以下任务:创建网站、创建应用程序池、创建 ActiveDirectory 用户、运行FxCop、配置虚拟服务器、创建 zip 文件、配置COM+、创建文件夹共享、安装到 GAC、配置SQL Server、配置 BizTalk 2004 和 BizTalk 2006 等。

回答by Ray

Using a dynamic scripting language like Python, BOO, Ruby, etc. to create and maintain build scripts might be a good alternative to an XML based one like NAnt. (They tend to be cleaner to read than XML.)

使用 Python、BOO、Ruby 等动态脚本语言来创建和维护构建脚本可能是替代基于 XML 的脚本语言(如 NAnt)的不错选择。(它们往往比 XML 更易于阅读。)