I am working on a build script for an Azure web role project. The script will run on a build server, so using VS is a non-starter.
I can build the project using MSBuild and use CmdLets for Azure to handle the deployment (via PowerShell). The part that is missing is the creation of the cloud package. I can use the CSPack.exe tool that is included in the SDK, but I would like to use MSBuild tasks if possible, as that way I can leverage the build configuration options and integrate the creation of the package with the rest of the process.
I've dug around in the Azure web deployment project, but I can't find any references to the CSPack task. There might be some VS magic happening here, unless I am missing the file that references the CSPack/Azure tasks. The assembly that I am looking at is Microsoft.ServiceHosting.Tools.MSBuildTasks.dll - reflector tells me that the CSPack Task is in there.
Has anyone successfully used the CSPack MSBuild task? If so, any pointers as to how to use it would be very helpful!
If I am barking up the completely wrong tree, please let me know!
Thanks, Erick
The CSpack task is part of Microsoft.CloudService.Targets msbuild file. On a default install this is at
C:\Program Files (x86)\MSbuild\Microsoft\CloudService\1.0\Visual Studio 10\
You'll see the reference to this in any .ccproj (cloud service) project
<CloudExtensionsDir Condition=" '$(CloudExtensionsDir)' == '' ">$(MSBuildExtensionsPath)\Microsoft\Cloud Service\1.0\Visual Studio 10.0\</CloudExtensionsDir>
<Import Project="$(CloudExtensionsDir)Microsoft.CloudService.targets" />
From there you can get the basic format and several variations. As an example, this is the CorePublish target using it
<CSPack
ServiceDefinitionFile="@(ServiceDefinitionCopy)"
Output="$(OutDir)Publish\$(ProjectName).cspkg"
PackRoles="@(Roles)"
SiteMapping="@(SiteMapping)"
RoleProperties="@(RoleProperties)"
CopyOnly="false"
>
</CSPack>
We invoke this way to generate our cloud packages. If t here is a particular scenario you are needing advice on, please provide that detail. Our usage is pretty common, we just (like you) had no interested in using msbuild to invoke out to the command line.
So piecing everything together, one can simply issue
msbuild MyAzureProject.ccproj /t:CorePublish
or if you have a solution with multi-leveled project folders and want to package the Release bits
msbuild MyAzureProject\MyAzureProject.ccproj /t:CorePublish /Property:SolutionDir=..\ /p:Configuration=Release
I am using them but I have Visual Studio and the Azure SDK 1.3 installed on the build servers. I could not find any way around that. You may get away with using Visual Studio Express on the build servers so you may want to give that a try first.
I am just using
<Exec Command="$(PackageCommand)" WorkingDirectory="$(BuildProjectFolderPath)\..\main\source\" />
where PackageCommand is what you use in the command line to call cspack.exe.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With