Skip to content

Instantly share code, notes, and snippets.

@domgreen
Created April 26, 2011 12:24
Show Gist options
  • Save domgreen/942164 to your computer and use it in GitHub Desktop.
Save domgreen/942164 to your computer and use it in GitHub Desktop.
MSBuild script using tools to deploy Windows Azure package locally or to the public cloud
<?xml version="1.0" encoding="utf-8"?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<CloudExtensionsDir Condition=" '$(CloudExtensionsDir)' == '' ">
C:\Program Files (x86)\MSBuild\Microsoft\Cloud Service\1.0\Visual Studio 10.0\
</CloudExtensionsDir>
</PropertyGroup>
<Import Project="$(CloudExtensionsDir)Microsoft.CloudService.targets" />
<PropertyGroup>
<AccountConnectionString>...</AccountConnectionString>
<!-- <AccountConnectionString>UseDevelopmentStorage=true</AccountConnectionString>-->
<BlobStorageEndpoint>...</BlobStorageEndpoint>
<hostedService>testcloudproject</hostedService>
<deploymentSlot>production</deploymentSlot>
<deploymentLabel>test</deploymentLabel>
<DeployType>Cloud</DeployType>
<SuspendedStatus>suspended</SuspendedStatus>
<RunningStatus>running</RunningStatus>
<!-- commands and locations -->
<PublishLocation>$(OutDir)Publish\</PublishLocation>
<PackageUploader>$(SolutionRoot)..\Build\AzurePackageUploader.exe</PackageUploader>
<cspkgFile>$(PublishLocation)$(ProjectName).cspkg</cspkgFile>
<CreateCommand>csmanage /create-deployment /hosted-service:$(hostedService) /slot:$(deploymentSlot) /name:$(hostedService) /label:$(deploymentLabel) /package:$(BlobStorageEndpoint)packages/$(ProjectName).cspkg /config:$(PublishLocation)ServiceConfiguration.cscfg</CreateCommand>
<UpdateStatusCommand>csmanage /update-deployment /hosted-service:$(hostedService) /slot:$(deploymentSlot)</UpdateStatusCommand>
<RunCommand>$(UpdateStatusCommand) /status:$(RunningStatus)</RunCommand>
<SuspendCommand>$(UpdateStatusCommand) /status:$(SuspendedStatus)</SuspendCommand>
<DeleteCommand>csmanage /delete-deployment /hosted-service:$(hostedService) /slot:$(deploymentSlot)</DeleteCommand>
<StopLocalDevFabric>csrun /devfabric:shutdown</StopLocalDevFabric>
<RunLocalDevFabric>csrun /run:$(OutDir)\$(ProjectName).csx;ServiceConfiguration.cscfg /launchbrowser</RunLocalDevFabric>
</PropertyGroup>
<Target Name="Deploy" AfterTargets="Build" DependsOnTargets="CloudDeploy;LocalDeploy"/>
<Target Name="CloudDeploy" DependsOnTargets="CorePublish" Condition=" '$(DeployType)' == 'Cloud' ">
<Exec Command="$(PackageUploader) $(cspkgFile) $(AccountConnectionString)"/>
<Exec Command="$(SuspendCommand)" ContinueOnError="true"/>
<Exec Command="$(DeleteCommand)" ContinueOnError="true"/>
<Exec Command="$(CreateCommand)" ContinueOnError="true"/>
<Exec Command="$(RunCommand)" ContinueOnError="true"/>
</Target>
<Target Name="LocalDeploy" DependsOnTargets="CorePackageComputeService" Condition=" '$(DeployType)' == 'Local' ">
<Exec Command="$(StopLocalDevFabric)"/>
<Exec Command="$(RunLocalDevFabric)" />
</Target>
</Project>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment