NAnt or MSBuild, which one to choose and when?

前端 未结 14 764
你的背包
你的背包 2020-11-27 09:15

I am aware there are other NAnt and MSBuild related questions on Stack Overflow, but I could not find a direct comparison between the two and so here is the question.

14条回答
  •  野趣味
    野趣味 (楼主)
    2020-11-27 09:41

    One thing I noticed several posters mention was having to hand edit the .csproj (or .vbproj, etc.) files.

    MSBuild allows customization of these .*proj files through the use of .user files. If I have a project named MyCreativelyNamedProject.csproj and want to customize the MSBuild tasks inside of it, I can create a file named MyCreativelyNamedProject.csproj.user and use the CustomBeforeMicrosoftCommonTargets and CustomAfterMicrosoftCommonTargets to customize those files.

    Also, both NAnt and MSBuild can be customized to the heart's content through custom MSBuild tasks and through NantContrib extensions.

    So, using NAnt or MSBuild really comes down to familiarity:

    • If you are already familiar with Ant, use NAnt. The learning curve will be very easy.
    • If you are not familiar with either tool, MSBuild is integrated with Visual Studio already and requires no additional tools.

    It is also worth adding that MSBuild is pretty much guaranteed to work with all new versions of .NET and Visual Studio as soon as they are released, whereas NAnt may have some lag.

提交回复
热议问题