3-Team Build Activities part 1



Today I will start introduce some of the important activities in the Team build 2010 as the following picture

Activities Toolbox

Activities Toolbox

So this process has 3 main steps as the following

Build Process main task

Build Process main task

  • GetBuildDetail Activity

This activity will return the Build Detail object which hold all information needed about the build, you need to declare a variable of type IBuildDetail to hold the object when return

BuildDetail

BuildDetail

If we print the BuildDetail variable .ToString we will find the following information, remember you can retrieve any info you find in the ToString from the BuildDetail as needed

BuildDetail.ToString

BuildDetail.ToString

  • AgentScope Activity

This activity used to group all activities that need to run on the Build Agent

  • GetBuildAgent Activity

This activity must run on the Agent and inside AgentScope Activity, it will return the Build Agent object which hold all information needed about the Agent, you need to declare a variable of type IBuildAgent to hold the object when return

  • GetBuildDirectory Activity

This activity must run on the Agent and inside AgentScope Activity, it will return string of the path of the build directory

Notice that the variable Run on Agent in the picture because you must run them in the Agent

AgentScope and insiders

AgentScope and insiders

Notice that if we print the BuildAgent variable and BuildDirectory variable you will find all information needed for Agent and directory

Print buildAgent, print BuildDirectory

BuildAgent and BuildDirectory

BuildAgent and BuildDirectory

  • Assign Activity

This activity used to assign a string variable a value

  • AddToCollection Activity

This activity used to add item to collection you can use it with the ForEach Activity to add the item in a collection for each iteration

  • FindMatchingFiles

This Activity will find the files with specified pattern and return them as collection of IEnumrable<String>

  • InvokeForReason Activity

This Activity will invoke based on the build trigger remember this trigger is flag enumeration which mean you can choose more than one option for invoke

Other activities

Other activities

MatchFile Pattern

MatchFile Pattern

Finaly I will print out all the variables and I will use ForEach Activity to iterate over the collection that hold matches files to print all files

Print the variables

Print the variables

The value will be as the following:

The value of the print

The value of the print

Remember BuildSettings and AgentSetting which will display the option the process definition

BuildSettings AgentSettings

BuildSettings AgentSettings

Finished, wait me for Activities part 2

You can download the process from the following

Download

Download

Microsoft vs. Others



I work in a company that has different technology environment so most of the time you find other technology people said jokes about Microsoft, how is the .NET is very simple and it just drag and drop solution and we as a developer didn’t do anything except drag and drop, how Microsoft system are bugy and not working well, you will find many videos on the internet mention some issues regarding Microsoft, but guess what? You will not find any video saying Java or PHP or Google is bad, so what does it mean? We don’t care!! Microsoft is a big successful story and so it has many enemies, and this what they called the enemies of success.

I have some issues with Microsoft products too like any other products (Zero defect is not possible)  but you have to be fair when you compare between Airplane and bicycle, most of the time I see this comparison happen and just mention issues and of-cures the biggest  is more issues it will has, but how about the features and the integration comparison ???  No one talk about it!!!

So lets me category those people that they said or talk about Microsoft technology in a bad way

  • Microsoft technology failure’s
    These people start with Microsoft and fail to be good not because Microsoft it’s not good but because they are failures and losers
  • Shallow people
    They don’t know anything, they didn’t even know  what exist and Microsoft can perform but just repeat what they hear and what the others said it just a drag and drop technology ???, these are very stupid and what they said is the prove what they are, I challenge anyone of them to prove of what he exactly  knows about Microsoft technology ????, they just know names so let me say to them (Did you know how many products Microsoft produce and how these products integrated  with each other ???) Your answer is far more than you can imagine from the truth, so they didn’t even know the names?????
  • Racial People
    They just hit anything else, they didn’t like anyone has different idea or method, they are haters

Of-curse there is a good people they are very respect to Microsoft technology as we respect them but they out of the scope.

So let’s Summary the categories, Failures, Shallow and Haters, WOW that’s exactly what they are

Automate the best practice for check-in, including Get latest, deploy DB, Run test, check-in



To make sure that all my team members didn’t make any mistake when they check-in their pending change, I decide to write a best practice document that tell them what they have to do when they check-in their code, but what about automation and the key concept Automate every repeated tasks so I decide to automate these best practices and write an article describe how to do that, and this post also will prove that anything you need can be automated

So here the process that will be automated

  • Get the latest change from TFS
  • Build the solution including all projects
  • Deploy the Main Database locally
  • Deploy the Test Database locally which hold the test data used in the data driven test
  • Run the sanity test or  BVT (Build Verification Test) which has belong to category 1 (Test the integration between DB and code)
  • Check-in the pending change

You can download the project from here download

I will create a new configuration called DebugForCheck-in, see the following

Project file

Project file

You can also see the project configuration file as XML, see the following

<Target Name="GetLatestFromTFS2010" AfterTargets="build" >
 <Message Importance="high" Text ="start GetLatest for the project "></Message>
 <Exec Command='"C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\TF.exe" get $/AutoDBand/AutomateDatabaseAndTest/AutomateDatabaseAndTest /recursive /login:YourUsername,YourPassword' ContinueOnError='false'/>

 </Target>
 <!--===========Deploy Database============-->
 <Target Name="DeployDatabase" AfterTargets="GetLatestFromTFS2010" Condition="'$(Configuration)' == 'DebugForCheck-in'">
 <Message Importance="high" Text="-------------------------------- Deploying Database according to the connection string -------------------------------- " />
 <Message Importance="high" Text=" "/>
 <MSBuild Projects="..\DB\DB.dbproj" Targets="Build;Deploy" />
 </Target>

 <!--============Run the Test==================-->
 <Target Name="UnitTests" AfterTargets="DeployDatabase" Condition="'$(Configuration)' == 'DebugForCheck-in'">
 <Message Importance="high" Text="--------------------------------  Running Unit Tests for category 1 only--------------------------------"  />
 <Message Importance="high" Text=" "/>
 <Exec Command='"C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\mstest.exe" /testcontainer:"..\BLTest\bin\Debug\BLTest.dll" /category:cat1' />
 </Target>

 <Target Name="Chekin-pendingChange" AfterTargets="UnitTests" >
 <Message Importance="high" Text ="-------------------------------- start Check-in process-------------------------------- "></Message>
 <Message Importance="high" Text=" "/>
 <Exec Command='"C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\TF.exe" checkin $/AutoDBand/AutomateDatabaseAndTest/AutomateDatabaseAndTest /recursive /login:YourUsername,YourPassword' ContinueOnError='false'/>
 </Target>

That’s it, have fun :-)

How to include minify files or custom files with web pagckage or MS Deploy package?



Wow it was a large title any way, I suppose now to sit and finishing my proposal of my Mcs and if the Dr read this article she will tell me, What the hell you are doing?? you should finish your proposal but I couldn’t prevent my self from writing this post because it’s very important article to me any way.

If you read most of my articles you will know that I am working on an MVC project and I am using TFS2010 and I automate the whole building process including deployment of database and Test database for Data driven test, running test, deploy database to QA machine and finally create the deploy package and deploy the website to the IIS of the QA machine.

I have some issues, I just doing some workarounds until solve it at a proper time, so now the time come for one of the most important issues which is the minify files didn’t included in the MS deploy package so the deployment of the website didn’t deploy this files

I read a wonderful article to sayed.hashimi, you always impressed me Sayed!!

But it needs a little tweaking to work with minify fiels and I found a question on StackOverFlow which is “  How can we include the files created by ajaxmin in the msdeploy package created by MSBuild ” so I decide to post an article describe my tweaking to solve this issue.

First you can download the whole project which successfully include the minify file in the MS Deploy package from here Download

First you need to create include for each folder in your application that has minify files and this will has source and destination folder so you make sure you didn’t copy the minify file in every script folder in your application as the following

SolSolution file that show the scripts in your project

SolSolution file that show the scripts in your project

You need to follow the image or just download the project as mention before

MVCProject file.csproj

MVCProject file.csproj

You can also see the text version here


<!-- ======== Minify files ========= -->
 <Import Project="$(MSBuildExtensionsPath)\Microsoft\MicrosoftAjax\ajaxmin.tasks" />
 <Target Name="AfterBuild">
 <ItemGroup>
 <JS Include="**\*.js" Exclude="**\*.min.js;Scripts\*.js" />
 </ItemGroup>
 <ItemGroup>
 <CSS Include="**\*.css" Exclude="**\*.min.css" />
 </ItemGroup>
 <AjaxMin JsSourceFiles="@(JS)" JsSourceExtensionPattern="\.js$" JsTargetExtension=".min.js" CssSourceFiles="@(CSS)" CssSourceExtensionPattern="\.css$" CssTargetExtension=".min.css" />
 </Target>

<!-- ====== Package the minify fiels ===== -->

 <PropertyGroup>
 <CopyAllFilesToSingleFolderForPackageDependsOn>
 CustomCollectFiles;
 $(CopyAllFilesToSingleFolderForPackageDependsOn);
 </CopyAllFilesToSingleFolderForPackageDependsOn>
 </PropertyGroup>
 <Target Name="CustomCollectFiles">
 <ItemGroup>
<!-- =====Root folder ==== -->
 <_CustomFilesForRootFolder Include="MyScript\*.min.js">
 <DestinationRelativePath>%(RecursiveDir)%(Filename)%(Extension)</DestinationRelativePath>
 </_CustomFilesForRootFolder>
 <FilesForPackagingFromProject Include="%(_CustomFilesForRootFolder.Identity)">
 <DestinationRelativePath>MyScript\%(RecursiveDir)%(Filename)%(Extension)</DestinationRelativePath>
 </FilesForPackagingFromProject>

<!-- ======sub folder ==== -->
 <_CustomFilesForSubFolder1 Include="MyScript\Login\*.min.js">
 <DestinationRelativePath>%(RecursiveDir)%(Filename)%(Extension)</DestinationRelativePath>
 </_CustomFilesForSubFolder1>
 <FilesForPackagingFromProject Include="%(_CustomFilesForSubFolder1.Identity)">
 <DestinationRelativePath>MyScript\Login\%(RecursiveDir)%(Filename)%(Extension)</DestinationRelativePath>
 </FilesForPackagingFromProject>

<!-- === another sub folder ==== -->
 <_CustomFilesForSubFolder2 Include="MyScript\Registration\*.min.js">
 <DestinationRelativePath>%(RecursiveDir)%(Filename)%(Extension)</DestinationRelativePath>
 </_CustomFilesForSubFolder2>
 <FilesForPackagingFromProject Include="%(_CustomFilesForSubFolder2.Identity)">
 <DestinationRelativePath>MyScript\Registration\%(RecursiveDir)%(Filename)%(Extension)</DestinationRelativePath>
 </FilesForPackagingFromProject>

 </ItemGroup>
 </Target>

That’s it