When running an automated build to deploy your application into Windows Azure you need to at some point run a packaging script, this will take all the components of your application and turn them into a .cspkg file ready to be deployed to Azure with the correct configuration.
I would have normally done this using the CSPack Tool and something like this:
This shows a CSPack command creating a web and worker role for an application (tokenized).
This gets annoying to keep updating and can actually get quite confusing especially when the SDK upgrades and you need to go and figure out what changes you need to make to your packing command to ensure the .cspkg file is created correctly.
However, there is good news coming … if you are using MSBuild you can call upon the build targets that are part of the Windows Azure SDK and allow it to do all of the packaging for you.
The targets are typically located here:
C:\Program Files (x86)\MSBuild\Microsoft\Cloud Service\1.0\Visual Studio 10.0\Microsoft.CloudService.targets
You can then add these targets to your own MSBuild targets like so:
Then call on the following targets:
- CorePublish – This packages up your application as a .cspkg file to be published into the public cloud
- CorePackageComputeService – This packages the application so that it can be run on the local development fabric.
These two targets use the CSPack command under the hood but allows you to defer the responsibility to the Azure targets rather than having to write the CSPack command yourself.
Here is how I have used these targets on a previous project: