How to start a Continuous Integration process is a difficult task. When things are up and running with Automated Process, it seems very helpful and easy to maintain. With minimal human interaction you can reduce your build time and accuracy and hence time to market the application. A great advantage.
There are a large set of options and combination of tools. We prepared a dedicated Build server machine in the company (TEO). Here is a set of software components on Build Server, I will discuss about each component’s wiring later on (decision about set of chosen package is based on our defined criteria including wide acceptance, open source availability and our needs).
MsBuild Integration with csproj file:
Our target is command line building of CSharp project using MSBuild. I created an asp.net website in VS2010 and want to configure it to execute from command line tool. One goal is to copy the build files to root drive destination folder (also configured in metadata dynamically). So I unloaded the project file in VS and right clicked to go to “Edit project file”. It opens the project file for editing.
At the end of file we can find ‘Before Build’ and ‘After Build’ commented targets. In the after build target we will write custom code.
Here is my code snippet instead:
<!--MSBuild integration started here by Bash 20-Dec-2010-->
<Target Name="AfterBuild">
<Message Text ="Custom After Build Action Started" Importance="high"></Message>
<ItemGroup>
<ProjectFolder Include="$(ProjectDir)\*.*" Exclude="$(ProjectDir)\*.cs;$(ProjectDir)\*.csproj;$(ProjectDir)\*.user" >
<!--Only imediate file of project folder-->
<PublishTo>2010_MSBuild</PublishTo>
</ProjectFolder>
<BinFolder Include="$(ProjectDir)bin\**\*.*" Exclude="*.cs">
<!--All files and sub folders in bin-->
<BinFolderTo>2010_MSBuild/bin</BinFolderTo>
</BinFolder>
<AccountFolder Include="$(ProjectDir)Account\**\*.*" Exclude="$(ProjectDir)Account\**\*.cs" >
<!--All files and sub folders in Account-->
<AccountFolderTo>2010_MSBuild/Account</AccountFolderTo>
</AccountFolder>
<ScriptsFolder Include="$(ProjectDir)Scripts\**\*.*">
<!--All files and sub folders in Scripts-->
<ScriptsFolderTo>2010_MSBuild/Scripts</ScriptsFolderTo>
</ScriptsFolder>
<StylesFolder Include="$(ProjectDir)Styles\**\*.*">
<!--All files and sub folders in Styles-->
<StylesFolderTo>2010_MSBuild/Styles</StylesFolderTo>
</StylesFolder>
</ItemGroup>
<Message Text="ProjectFolder :@(ProjectFolder)" Importance="high"/>
<Copy SourceFiles="@(ProjectFolder)" DestinationFiles="@(ProjectFolder->'%(RootDir)%(PublishTo)\%(Filename)%(Extension)')" />
<Copy SourceFiles="@(BinFolder)" DestinationFiles="@(BinFolder->'%(RootDir)%(BinFolderTo)\%(Filename)%(Extension)')" />
<Copy SourceFiles="@(AccountFolder)" DestinationFiles="@(AccountFolder->'%(RootDir)%(AccountFolderTo)\%(Filename)%(Extension)')" />
<Copy SourceFiles="@(ScriptsFolder)" DestinationFiles="@(ScriptsFolder->'%(RootDir)%(ScriptsFolderTo)\%(Filename)%(Extension)')" />
<Copy SourceFiles="@(StylesFolder)" DestinationFiles="@(StylesFolder->'%(RootDir)%(StylesFolderTo)\%(Filename)%(Extension)')" />
</Target>
Now save the project file.
Open VS2010 command line tool and browse to the folder where csproj file exists. Execute this command:
>>> MSbuild GD.AutoDist.MainService.csproj /p:Configuration=Release
1. MsBuild – Standard command
2. Cs project file to be built
3. /p is parameter with key-value pair; key= configuration and value=release
After build, the files will copy to root’s 2010_MSBuild folder.
Now next target is to analyze the code by Static Code Analysis. FxCop is the goal for integration.
Now next target is to analyze the code by Static Code Analysis. FxCop is the goal for integration.
No comments:
Post a Comment