Thursday, August 17, 2006
Automate build of Windows Moble CAB file from NAnt
We call MSBuild from NAnt to build our software, and it has worked really well up to now, but we came across an issue with building our new mobile software. This is a Windows Mobile 2003 device app, and the output of the release is a CAB file that you can deploy on the mobile devices.
The problem comes from the fact that MSBuild does not support building deployment projects, including mobile CAB files. When I tried to build the CAB project using MSBuild, the NAnt log showed this message:
warning MSB4078: The project file "MyCAB.vddproj" is not supported by MSBuild and cannot be built.
The workaround I found was to use devenv from the command line.
"c:\program files\Microsoft Visual Studio 8\Common7\IDE\devenv" C:\dev\MyMobileApp.sln /build release /safemode
Use the /build switch instead of the /deploy, since the /deploy switch will try to launch the software in the emulator or on a activesynch'd device.
I used the /safemode flag because it ostensibly loads a minimal set of drivers for stability. It is probably not necessary, though.
To get this working in NAnt, I added some code to a custom NAnt task that was already running for this project like this (inside XML tags):
exec
program="c:\program files\Microsoft Visual Studio 8\Common7\IDE\devenv"
commandline="${vss.bin.dir}\Application\${application.name}.sln /Build Release /SafeMode"
****
I hope this post helps someone; this is probably pretty basic stuff, but I would've saved a couple of hours if I could've found this info in once place when I came across the problem.
UPDATE
I ran across some additional problems -- the CABs being created by devenv did not include all the assemblies that were referenced; the issue was that our automated build process was incrementing the version number on each build, and in order for the CAB to build correctly you need to manually "refresh dependencies" on the CAB project.
The final resolution was to download the Windows Mobile 2003 SDK and run "CabWiz" from the command line. I used the "inf" file that was generated by Visual Studio 2005 (make sure to convert it from Unicode to Ansi text first) and everything worked like a charm.
The problem comes from the fact that MSBuild does not support building deployment projects, including mobile CAB files. When I tried to build the CAB project using MSBuild, the NAnt log showed this message:
warning MSB4078: The project file "MyCAB.vddproj" is not supported by MSBuild and cannot be built.
The workaround I found was to use devenv from the command line.
"c:\program files\Microsoft Visual Studio 8\Common7\IDE\devenv" C:\dev\MyMobileApp.sln /build release /safemode
Use the /build switch instead of the /deploy, since the /deploy switch will try to launch the software in the emulator or on a activesynch'd device.
I used the /safemode flag because it ostensibly loads a minimal set of drivers for stability. It is probably not necessary, though.
To get this working in NAnt, I added some code to a custom NAnt task that was already running for this project like this (inside XML tags):
program="c:\program files\Microsoft Visual Studio 8\Common7\IDE\devenv"
commandline="${vss.bin.dir}\Application\${application.name}.sln /Build Release /SafeMode"
****
I hope this post helps someone; this is probably pretty basic stuff, but I would've saved a couple of hours if I could've found this info in once place when I came across the problem.
UPDATE
I ran across some additional problems -- the CABs being created by devenv did not include all the assemblies that were referenced; the issue was that our automated build process was incrementing the version number on each build, and in order for the CAB to build correctly you need to manually "refresh dependencies" on the CAB project.
The final resolution was to download the Windows Mobile 2003 SDK and run "CabWiz" from the command line. I used the "inf" file that was generated by Visual Studio 2005 (make sure to convert it from Unicode to Ansi text first) and everything worked like a charm.
Comments:
<< Home
Thx for posting this - confirmed what I was seeing, too. Looks like taking the reins of the .inf file is the best way to go for automation.
Post a Comment
<< Home