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="http://schemas.microsoft.com/developer/msbuild/2003">

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

 

  <PropertyGroup>

    <Major>1</Major>

    <Minor>0</Minor>

    <Build>0</Build>

    <Revision>0</Revision>

  </PropertyGroup>

 

  <ItemGroup>

    <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" />

  </ItemGroup>

 

  <ItemGroup>

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

  </ItemGroup>

 

  <Target Name="Version">

    <SvnVersion LocalPath="$(MSBuildProjectDirectory)">

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

    </SvnVersion>

 

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

 

    <AssemblyInfo CodeLanguage="CS" 

      OutputFile="Source\MSBuild.Community.Tasks\Properties\AssemblyInfo.cs"

      AssemblyTitle="MSBuild Community Tasks"

      AssemblyDescription="Collection MSBuild Tasks"

      AssemblyCompany="http://msbuildtasks.tigris.org/"

      AssemblyProduct="MSBuild.Community.Tasks"

      AssemblyCopyright="Copyright © Paul Welter 2005"     

      ComVisible="false"

      CLSCompliant="true"

      Guid="d038566a-1937-478a-b5c5-b79c4afb253d"

      AssemblyVersion="$(Major).$(Minor).$(Build).$(Revision)"

      AssemblyFileVersion="$(Major).$(Minor).$(Build).$(Revision)"

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

 

  </Target>

 

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

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

             Properties="Configuration=Release" />

  </Target>

 

  <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>

 

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

    <Zip Files="@(ZipFiles)"

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

  </Target>

 

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

    <Message Text="CodeSmith Build Complete"/>

  </Target>

 

</Project>

 

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

~ Paul

 

Published Monday, December 05, 2005 12:27 PM by pwelter34
Filed under:

Comments

# re: Sample build file using MSBuild Community Tasks

Is there a reference available to show how to use some of the other tasks available? I've searched high and low and there is seems to be a dearth of information on how to use them.

Monday, August 14, 2006 11:46 AM by John

# re: Sample build file using MSBuild Community Tasks

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.

Friday, July 27, 2007 6:33 AM by Francis Norton

# Sample build file using MSBuild Community Tasks

Pingback from  Sample build file using MSBuild Community Tasks

Monday, November 26, 2007 6:16 AM by Sample build file using MSBuild Community Tasks

# re: Sample build file using MSBuild Community Tasks

Thank you very much.  I managed to copy the code from your <Target Name="Version"> into the <Target Name="BeforeBuild"> of my VB project and now I have svn revision numbers showing in my application.  That'll put an end to users lying about which version of the app they are running.

Thursday, May 29, 2008 5:05 AM by Jonty

# re: Sample build file using MSBuild Community Tasks

Thanks a lot for this helpful stuff.

Could you please tell me how to set the output Path for the build in the text file which i am passing to MSBuild to build my application. The code i am writing is as follows:

<Project xmlns="schemas.microsoft.com/.../2003" >

   <PropertyGroup>

         <OutputPath>D:/MyBuild</OutputPath>

   </PropertyGroup>

   <Target Name="default">

 <MakeDir Directories= "$(OutputPath)"/>

         <MSBuild Projects="d:/App1/App1.sln" />

   </Target>

</Project>

But it is not copying the build at the specified directory.

Thursday, June 05, 2008 9:21 AM by Sukh

# re: Sample build file using MSBuild Community Tasks

Good to start with ..

Friday, July 04, 2008 5:22 AM by Sumit

# re: Sample build file using MSBuild Community Tasks

Great! quite helpful

Tuesday, October 20, 2009 11:38 PM by jack.niu

# re: Sample build file using MSBuild Community Tasks

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

Monday, February 22, 2010 3:12 PM by Symmetry

# &raquo; MSBuild Community Tasks Ordinary Mind

Pingback from  &raquo; MSBuild Community Tasks Ordinary Mind

Monday, March 15, 2010 9:39 PM by » MSBuild Community Tasks Ordinary Mind

# re: Sample build file using MSBuild Community Tasks

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 <Target Name="Version"> into the <Target Name="BeforeBuild"> 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.

Thursday, March 18, 2010 11:08 AM by Qing Xue

# re: Sample build file using MSBuild Community Tasks

My problem solved. I fund another great article.

solutionmania.com/.../automatically-adding-svn-revision-numbers-to-assemblies

Thanks for your article.

Thursday, March 18, 2010 12:00 PM by Qing Xue

# re: Sample build file using MSBuild Community Tasks

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

Thursday, May 20, 2010 5:12 AM by Renis

# re: Sample build file using MSBuild Community Tasks

I have a msbuild file, mydeploy.targets, to deploy WebSite in remote machine.

I want to do backup (of files of remote machine) for each deployment.

I need ZIP a folder in remote machine, for generate ZIP file of all folder (all contents files, folders), and the name of zip using Time and Date actual; and copy zip in a folder named Backup, in remote machine.

thanks

Tuesday, July 20, 2010 2:43 AM by kiquenet@gmail.com

# re: Sample build file using MSBuild Community Tasks

Ведущее направление деятельности нашей компании - это вывоз мусора на территории Москвы и Московской области. Мы работаем только при использовании современной техники из собственного автопарка и всеми видами отходов: строительного мусора, ТБО и других видов для нас не составляет проблемы. Заказать уборку мусора Вы можете в том числе и на ночное время, и на выходные дни.

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

Мы осуществляем комплекс работ по механизированной уборке территории и вывозу мусора. Вывозить мусор мы будем как и с помощью 8-ми кубовых контейнеров, так и с помощью 26-кубовых. Мехуборка является достаточно сложным комплексом работ по сбору, погрузке и утилизации отходов, для которой требуются квалифицированные специалисты. Мы предоставим Вам решение по вывозу мусора в Москве - под ключ.

Wednesday, August 04, 2010 9:17 AM by astprofi

# re: Sample build file using MSBuild Community Tasks

Sir,

I saw it:

<SvnVersion LocalPath="$(MSBuildProjectDirectory)">

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

   </SvnVersion>

But, i don't know What SvnVersion with LocalPath

I use Tortoise, So, how can i get it?

Wednesday, August 04, 2010 10:58 AM by Phong Tran

# re: Sample build file using MSBuild Community Tasks

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

Wednesday, August 18, 2010 11:00 AM by Benjamin Baumann

# re: Sample build file using MSBuild Community Tasks

Don't you acknowledge that this is the best time to get the <a href="http://bestfinance-blog.com">loans</a>, which would realize your dreams.

Friday, September 10, 2010 10:13 AM by CarsonRUTH

# re: Sample build file using MSBuild Community Tasks

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?

Thanks

Tuesday, September 14, 2010 8:50 AM by Khanh

# re: Sample build file using MSBuild Community Tasks

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.

Wednesday, September 15, 2010 4:01 PM by thesis writing service

# re: Sample build file using MSBuild Community Tasks

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.

Wednesday, September 15, 2010 9:16 PM by dissertation help

# re: Sample build file using MSBuild Community Tasks

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.

Monday, September 20, 2010 11:10 PM by writing papers

# re: Sample build file using MSBuild Community Tasks

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.

Thursday, September 23, 2010 6:07 AM by custom writing

# re: Sample build file using MSBuild Community Tasks

Здравствуйте! у меня такая ситуация нелепая. Мы с парнем знакомы уже три года, первый просто общались, второй - у него была девушка, у меня парень, но нас друг к другу очень тянуло и мы иногда целовались, а уж как чуть больше года встречаемся. когда начали встречаться, он прекратил общение со своей бывшей, потому что мне было это очень тяжело.но течение всего года, я сама упоминала, о ней спрашивала, ревновала к прошлому, к ней и каждый раз хотела услышать, что я лучше него. говорил, когда спрашивала. бросил ее он сам. но был не против общаться друзьями. ради меня не стал. прошел год, за который я очень часто говорила о ней, сама ему напоминая. дура> <. мы часто мелко ссорились последние месяцы, но знали, что любим друг друга и нужны. в начале сентября я узнала, что он начал общаться с прежней, говорил, что просто друзья и ему интересно с ней общаться. я была в шоке. много наговорила.на эмоциях сказала, что расстаемся в таком случае. сейчас понимаю, глупо. он отшучивался и говорил, что это ерунда, а наутро согласился с расставанием. я считала, что это просто ссора.но нет. с ней он сейчас очень много общается - переписывается, гуляет. но по-прежнему говорит, что это дружба

http://seexi.net

Sunday, September 26, 2010 10:00 PM by Rinatkaallka

# re: Sample build file using MSBuild Community Tasks

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.                              

Thursday, October 07, 2010 7:54 PM by custom dissertation

# re: Sample build file using MSBuild Community Tasks

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.

Saturday, October 09, 2010 2:07 PM by thesis

# re: Sample build file using MSBuild Community Tasks

Great Post. Very Intuitive

Monday, November 08, 2010 6:51 AM by Write Essay

# re: Sample build file using MSBuild Community Tasks

This sample project helps alot. thanks

Monday, November 08, 2010 7:00 AM by Custom Research

# re: Sample build file using MSBuild Community Tasks

Is there any another way to do the community task?

Regards,

Mac Grey

Tuesday, November 09, 2010 2:28 AM by good essay

# Msbuild example | Migrainemanual

Pingback from  Msbuild example | Migrainemanual

Friday, December 09, 2011 2:06 PM by Msbuild example | Migrainemanual