Sample build file using MSBuild Community Tasks

The MSBuild Community Tasks Project has released the first version of tasks.  The following is a sample build project that uses the SvnVersion, AssemblyInfo, NDoc and Zip tasks to create a release.


Import Targets


The first thing that needs to be done in the build file is to import the MSBuild.Community.Tasks.Targets file that defines the available tasks.  If you use the msi installer to install the MSBuild Community Tasks, you can use the path "$(MSBuildExtensionsPath)\MSBuildCommunityTasks\MSBuild.Community.Tasks.Targets". 


Version Target


The first target in the sample file is the Version target.  The version target is used to update the latest version number.  First the SvnVersion task is used to get the latest Revision number from the local working subversion repository.  SvnVersion outputs the Revision to the Revision property.


Next the target uses the AssemblyInfo task to generate an AssemblyInfo.cs file with the attributes specified.


Compile Target


The compile target calls msbuild to compile the solution in release mode.  The MSBuild target will compile the solution the exact same way Visual Studio will.


Documentation Target


To create help for the project, there is the documentation target.  In the documentation target, the NDoc task is used to compile a HTML Help project.  To use the NDoc task, you must have NDoc 1.3.1 installed.


The generated HTML Help file is then moved to the documentation folder and the temp files are cleaned up.


Zip Target


The zip target is used to package up the whole project into a zip file.  Zip target uses the Zip task to create the zip.  The files included in the zip are selected by the ItemGroup ZipFiles. 



Sample Master.proj File


<?xml version="1.0" encoding="utf-8"?>

<Project DefaultTargets="Build" xmlns="">

  <Import Project="$(MSBuildExtensionsPath)\MSBuildCommunityTasks\MSBuild.Community.Tasks.Targets"/>










    <DefaultExclude Include="**\.svn\**" />

    <DefaultExclude Include="**\bin\**" />

    <DefaultExclude Include="**\obj\**" />

    <DefaultExclude Include="**\Release\**" />

    <DefaultExclude Include="**\Debug\**" />

    <DefaultExclude Include="**\Test\**" />

    <DefaultExclude Include="**\TestResults\**" />

    <DefaultExclude Include="**\doc\**" />

    <DefaultExclude Include="**\www\**" />

    <DefaultExclude Include="**\*.user" />

    <DefaultExclude Include="**\*.suo" />

    <DefaultExclude Include="**\*.zip" />

    <DefaultExclude Include="**\*.txt" />




    <ZipFiles Include="**\*.*" Exclude="@(DefaultExclude)" />



  <Target Name="Version">

    <SvnVersion LocalPath="$(MSBuildProjectDirectory)">

      <Output TaskParameter="Revision" PropertyName="Revision" />



    <Message Text="Version: $(Major).$(Minor).$(Build).$(Revision)"/>


    <AssemblyInfo CodeLanguage="CS" 


      AssemblyTitle="MSBuild Community Tasks"

      AssemblyDescription="Collection MSBuild Tasks"



      AssemblyCopyright="Copyright © Paul Welter 2005"     






      Condition="$(Revision) != '0' "/>




  <Target Name="Compile" DependsOnTargets="Version">

    <MSBuild Projects="Source\MSBuild.Community.Tasks.sln"

             Properties="Configuration=Release" />



  <Target Name="Documentation" DependsOnTargets="Compile">

    <NDoc Documenter="MSDN"

          ProjectFilePath="Documentation\MSBuild.Community.Tasks.ndoc" />


    <Copy SourceFiles="doc\MSBuild Community Tasks.chm"

          DestinationFiles="Documentation\MSBuild.Community.Tasks.chm" />


    <RemoveDir Directories="doc" />




  <Target Name="Zip" DependsOnTargets="Documentation">

    <Zip Files="@(ZipFiles)"

         ZipFileName="MSBuild.Community.Tasks.v$(Major).$(Minor).$(Build).$(Revision).zip" />



  <Target Name="Build" DependsOnTargets="Zip">

    <Message Text="CodeSmith Build Complete"/>





I hope this sample will help in creating build files for your project.

~ Paul



  • John, (or anyone else who gets here)

    The reference is available as a compiled help file in the main code download. Take care not to read it from a networked drive or you'll get "This program cannot display the webpage" like I did.

  • Good to start with ..

  • Great! quite helpful

  • Anyone have a sample MSbuild xml file where they get from source safe? I cant seem to find any examples of this

  • I would like to have more info from one of your reader, who's name is Jonty. I do the same thing as he mentioned -
    copy the code from your into the of VB project, but I didn't get the svn version number in AssemblyInfo.vb. I don't know why. I really appreciate your great help. If you couldn't find him, will you please give me some hint how I can use your ideal in VB? Thanks.

  • how can I add version file where last version number is revision number? (example

  • Ведущее направление деятельности нашей компании - это вывоз мусора на территории Москвы и Московской области. Мы работаем только при использовании современной техники из собственного автопарка и всеми видами отходов: строительного мусора, ТБО и других видов для нас не составляет проблемы. Заказать уборку мусора Вы можете в том числе и на ночное время, и на выходные дни.
    Мы проводим политику комплексного подхода: в большинстве случаев для клиента важна общая задача поддержания чистоты подхозяйственной ему территории. Это означает, что в рамках этого подхода мы проводим не только работы по сбору ТБО, загрузке и его утилизации. Компания “Экопарк” имеет возможность реализовывать весь комплекс работ по механизированной уборке территории. Начиная с продажи контейнеров или сдачи бункеров / контейнеров в аренду, завершая уборкой строительного мусора со стройплощадок. Услуга вывоза мусора в таких случаях выступает лишь как часть общего проекта чистоты и уборки территории.
    Мы осуществляем комплекс работ по механизированной уборке территории и вывозу мусора. Вывозить мусор мы будем как и с помощью 8-ми кубовых контейнеров, так и с помощью 26-кубовых. Мехуборка является достаточно сложным комплексом работ по сбору, погрузке и утилизации отходов, для которой требуются квалифицированные специалисты. Мы предоставим Вам решение по вывозу мусора в Москве - под ключ.

  • Sir,

    I saw it:

    But, i don't know What SvnVersion with LocalPath
    I use Tortoise, So, how can i get it?

  • To have your revision number with tortoise svn you can do "show log" then the first revision number is the good one.

  • when I copy and paste the code, there are always under-blue-line under the word "ZipFiles","SvnVersion"....

    Why is that?
    How to solve it?

  • If you don't go after what you require, you'll never have it. If you don't ask, the reaction is regularly no. If you don't get used to thesis writing , you're regularly in the invariable place.

  • Very sensational commentary. With gist being so necessary online, this is a surpassing outline for achieve new on that people will use for dissertation writing service.

  • Of course you can spend your money for sweets or different things, but, that cannot aid you to get good grades. You can spend your cash in a clever way, for example for writing a research paper organization.

  • Thnx a lot for your superb thought related to this post. But to see the masters’ writing service all students have to know some information just about paper writer.

  • You are making really interesting investigation close to this good post! So, the buy dissertation service and some custom thesis writing services, would take for the thesis topics.

  • With your help people have some knowledge just about dissertation writing! Moreover they order the fantastic dissertation subject about this good post from the custom thesis service.

  • Great Post. Very Intuitive

  • This sample project helps alot. thanks

  • Is there any another way to do the community task?
    Mac Grey

Comments have been disabled for this content.