06 Jul
Posted by kdutta in Development, Team Foundation System Build, Windows Mobile
A few months ago I sent out an email describing the process of setting up the Team Foundation Build System to play nicely with Smart Device Projects. This mail included: setting up the build machine to work with Smart Device Projects, account permissions, publish location, versioning, and also a workaround to making Smart Device CAB projects buildable by TFS. I’m sure other developers have had to or will have to go through the same pains of figuring this out, so I decided to publish it a la blog.
I hit 3 snags while working on this:
Build Service Setup and Permissions
Automatic Versioning
Microsoft has some generic MSBuild tasks available that can be used to handle this. They are a separate download from Visual Studio however. Here’s the relevant links:
</Project> tag:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | <!-- This will retrieve and increment a version number from a file on a network share --> <import Project="$(MSBuildProjectDirectory)\Microsoft.Sdc.Common.tasks" /> <target Name="BuildNumberOverrideTarget"> <!-- Now update the version number --> <versionnumber .Update VersionNumberConfigFileLocation="\\emsea100\path\to\Version.xml" SkipSourceControl="true" OnlyIncrementRevision="true"> <output TaskParameter="VersionNumber" PropertyName="BuildNumber" /> </versionnumber> </target> <!-- This will replace all version numbers in the assemblyinfo.cs files with the one from the share --> <!-- This target is called after Team build gets all the source files from TFS. --> <target Name="AfterGet" DependsOnTargets="VersionAssemblies" /> <target Name="VersionAssemblies"> <!-- Get the Assembly Info files.--> <createitem Include="$(SolutionRoot)\**\AssemblyInfo.cs;"> <output TaskParameter="Include" ItemName="AssemblyInfos"/> </createitem> <!-- Update the version numbers --> <file .Replace Force="true" Path="%(AssemblyInfos.FullPath)" NewValue="AssemblyVersion("$(BuildNumber)")" regularExpression="AssemblyVersion\(\"(\d+.\d+.\d+.\d+)\"\)" ignoreCase="true" /> </target> |
VersionNumberConfigFileLocation value to be configured for your publish machine and directory. You can also change the OnlyIncrementRevision to false so that the build number also gets autoincremented.Building a Smart Device CAB Project Using MSBuild
There is no “good” way to do this. I did this by creating a standard Smart Device CAB project, and then building it on my development machine. If your project is called SmartDeviceCab, in the SmartDeviceCab\Debug folder, there is a SmartDeviceCab.inf file. That file can be used as input to CabWiz.exe to create the file from a command prompt. I will be using the INF file of our recently released tool, Device IP Utility, as an example.
1=,”Common1″,,”C:\Users\kdutta\Documents\Visual Studio 2008\Projects\Device IP Utility\Device IP Utility - Production\EnterpriseMobile.WindowsMobile.IPUtil\bin\Release\” 2=,”Common2″,,”C:\Users\kdutta\Documents\Visual Studio 2008\Projects\Device IP Utility\Device IP Utility - Production\EnterpriseMobile.WindowsMobile.IPUtil\obj\Release\” 3=,”Common3″,,”C:\Users\kdutta\Documents\Visual Studio 2008\Projects\Device IP Utility\Device IP Utility - Production\EnterpriseMobile.WindowsMobile.Utilities\bin\Release\” 4=,”Common4″,,”C:\Users\kdutta\Documents\Visual Studio 2008\Projects\Device IP Utility\Device IP Utility - Production\EnterpriseMobile.WindowsMobile.Utilities\obj\Release\” 5=,”Common5″,,”C:\Users\kdutta\Documents\Visual Studio 2008\Projects\Device IP Utility\Device IP Utility - Production\WMIPUtil\obj\Release\” 6=,”Common6″,,”C:\Users\kdutta\Documents\Visual Studio 2008\Projects\Device IP Utility\Device IP Utility - Production\WindowlessControls\bin\Release\” 7=,”Common7″,,”C:\Users\kdutta\Documents\Visual Studio 2008\Projects\Device IP Utility\Device IP Utility - Production\WindowlessControls\obj\Release\” 8=,”Common8″,,”c:\Users\kdutta\Documents\Visual Studio 2008\Projects\Device IP Utility\Device IP Utility - Production\EnterpriseMobile.WindowsMobile.IPUtil.Interop\Windows Mobile 5.0 Smartphone SDK (ARMV4I)\Release\”
1=,”Common2″,,”C:\Documents and Settings\TFSBuild\Local Settings\Temp\Device IP Utility\Device IP Utility - Production\Binaries\Release\” 2=,”Common3″,,”C:\Documents and Settings\TFSBuild\Local Settings\Temp\Device IP Utility\Device IP Utility - Production\Binaries\Release\” 3=,”Common4″,,”C:\Documents and Settings\TFSBuild\Local Settings\Temp\Device IP Utility\Device IP Utility - Production\Binaries\Release\” 4=,”Common5″,,”C:\Documents and Settings\TFSBuild\Local Settings\Temp\Device IP Utility\Device IP Utility - Production\Binaries\Release\” 5=,”Common6″,,”C:\Documents and Settings\TFSBuild\Local Settings\Temp\Device IP Utility\Device IP Utility - Production\Binaries\Release\” 6=,”Common7″,,”C:\Documents and Settings\TFSBuild\Local Settings\Temp\Device IP Utility\Device IP Utility - Production\Binaries\Release\” 7=,”Common8″,,”C:\Documents and Settings\TFSBuild\Local Settings\Temp\Device IP Utility\Device IP Utility - Production\Binaries\Release\” 8=,”Common9″,,”C:\Documents and Settings\TFSBuild\Local Settings\Temp\Device IP Utility\Device IP Utility - Production\Binaries\Release\”
</Project> tag, insert the following:
1 2 3 4 5 6 | <!-- This will build a CAB file from an .inf file --> <target Name="BeforeDropBuild" DependsOnTargets="MakeCAB"/> <target Name="MakeCAB"> <message Text="Building a CAB file" Importance="normal"/> <exec Command=""C:\Program Files\Microsoft Visual Studio 9.0\SmartDevices\SDK\SDKTools\cabwiz.exe" "C:\Documents and Settings\TFSBuild\Local Settings\Temp\Device IP Utility\Device IP Utility - Production\Sources\EMIPUtil.inf" /compress /dest "C:\Documents and Settings\TFSBuild\Local Settings\Temp\Device IP Utility\Device IP Utility - Production\Binaries""/> </target> |
Sadly there is somewhat poor support for Smart Device Projects in TFSBuild, so making it work isn’t exactly elegant, but it works!
Koushik Dutta
Software Engineer
www.koushikdutta.commicrosoftsdccommon
One Response
Bookmarks about Utilities
24|Jan|2009 1[...] - bookmarked by 3 members originally found by onmountain on 2008-12-26 Automating Build Versioning and Publishing of Smart Device Projects… [...]
Leave a reply