Using MSBuild and CSPack task to package Azure roles

左心房为你撑大大i 提交于 2019-12-05 18:58:46

问题


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


回答1:


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




回答2:


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.




回答3:


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.



来源:https://stackoverflow.com/questions/4731665/using-msbuild-and-cspack-task-to-package-azure-roles

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!