80 likes | 207 Views
Tools of the Trade. using msbuild to automate packaging Nick Airdo Software Engineer Central Christian Church Email: nick.airdo@cccev.com Twitter: @ airdo Tweet using #RefreshCache. Monkey Tasks. Kill the monkey. Visual Studio Project. Unload Edit. the . csproj. < Project > .
E N D
Tools of the Trade using msbuild to automate packaging Nick Airdo Software Engineer Central Christian Church Email: nick.airdo@cccev.com Twitter: @airdo Tweet using #RefreshCache
Monkey Tasks Kill the monkey
Visual Studio Project Unload Edit
the .csproj <Project> . . . <ImportProject="$(MSBuildExtensionsPath)\MSBuildCommunityTasks\MSBuild.Community.Tasks.Targets" /> <PropertyGroup> <BuildDir>builds</BuildDir> </PropertyGroup> <TargetName="AfterBuild" DependsOnTargets="BuildPackageZip"> </Target> <!-- Clean old stuff --> <TargetName="DeleteFiles"> <ItemGroup> <OldFilesInclude="$(BuildDir)\tmp\**" /> </ItemGroup> <DeleteFiles="@(OldFiles)" /> </Target> Import Target Clean
Continued… … <!-- Prepare the files to be zipped --> <TargetName="CopyFiles" DependsOnTargets="DeleteFiles"> <ItemGroup> <CopyFilesInclude="*.cs" Exclude="MetricsByZip.cs;ArenaFamilySplitter.cs" /> <CopyFilesInclude="$(OutputPath)Arena.Custom.Cccev.Accountability.dll" /> <CopyFilesInclude="$(OutputPath)Arena.Custom.Cccev.AgentWorkers.dll" /> </ItemGroup> <ItemGroup> <SqlFilesInclude="Helpers\SQL\*“ /> </ItemGroup> <MakeDirDirectories="$(BuildDir)\tmp" Condition="!Exists('$(BuildDir)\tmp')" /> <MakeDirDirectories="$(BuildDir)\tmp\required-SQL" Condition="!Exists('$(BuildDir)\tmp\required-SQL')" /> <CopySourceFiles="@(CopyFiles)" DestinationFolder="$(BuildDir)\tmp" /> <CopySourceFiles="@(SqlFiles)" DestinationFolder="$(BuildDir)\tmp\required-SQL" /> </Target> … Copy
Continued… <!-- Create the package zip file --> <TargetName="BuildPackageZip" DependsOnTargets="CopyFiles“ Condition="'$(Configuration)' == 'Release'"> <ItemGroup> <ZipFilesInclude="$(BuildDir)\tmp\**" /> </ItemGroup> <VersionBuildType="Automatic" RevisionType="Automatic" Major="2009" Minor="1“> <OutputTaskParameter="Major" PropertyName="Major" /> <OutputTaskParameter="Minor" PropertyName="Minor" /> <OutputTaskParameter="Build" PropertyName="Build" /> <OutputTaskParameter="Revision" PropertyName="Revision" /> </Version> <ZipFiles="@(ZipFiles)" WorkingDirectory="$(BuildDir)\tmp\" ZipFileName="$(BuildDir)\Arena.Custom.Cccev.AgentWorkers-$(Major).$(Minor).$(Build).$(Revision).zip" ZipLevel="9" /> </Target> . . . </Project> Condition Version Zip
command line msbuild Arena.Custom.Cccev.AgentWorkers.csproj /property:Configuration=Release
Get Free Tasks MSBuild.Community.Taskshttp://msbuildtasks.tigris.org/ MSBuild Extension Packhttp://msbuildextensionpack.codeplex.com/